Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure blob storage upload fail

I have an Azure Blob Storage where I want to upload some files.

Index.cshtml

@using (Html.BeginForm("File_post", "MyController", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
    <div class="editor-label">
    <p>
        <input type="file" name="file" />
    </p>
        <input type="submit" value="Upload" />
    </div>
}

MyController.cs

public ActionResult File_post(HttpPostedFileBase file)
{
    CloudBlobContainer blobContainer = Initialize(); // This Initialize my blobContainer
    CloudBlockBlob blob;
    blob = blobContainer.GetBlockBlobReference("myfile");
    blob.UploadFromStream(file.InputStream);
    Return("Index");
}

I tested with a 3.5Mo file, it works even with a 20Mo file. Now I try with a 33Mo and firefox gives me the basic error : The connection was reset...

Edit: When I put

public ActionResult File_post(HttpPostedFileBase file)
{
    Return("Index");
}

It gives me the same error, so I think it's not caused by my c# code.

Any idea ? Thanks a lot !

like image 310
MaT Avatar asked Sep 27 '12 08:09

MaT


People also ask

How do I know if my Azure blob Storage upload was successful?

If no exception throws from your code, it means the blob has been uploaded successfully. Otherwise, a exception will be thrown. You can also confirm it using any web debugging proxy tool(ex. Fiddler) to capture the response message from storage server.


1 Answers

You'll need to modify your web.config to allow large file uploads in ASP.NET and IIS (the following example will allow a 50MB file upload):

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <system.web>
        <httpRuntime maxRequestLength="51200" />
    </system.web>
    <system.webServer>
        <security>
            <requestFiltering>
                <requestLimits maxAllowedContentLength="51200000" />
            </requestFiltering>
        </security>
    </system.webServer>
</configuration>
like image 88
Sandrino Di Mattia Avatar answered Oct 05 '22 11:10

Sandrino Di Mattia