0

While uploading 85mb file to the amazon server bucket from fileupload control , i get 404 error even after specifying 2gb limit in web.config

` <compilation debug="true" targetFramework="4.5"/>
    <httpRuntime maxRequestLength="2048000" requestLengthDiskThreshold="2048000" executionTimeout="600" enable="true"/>
    <pages controlRenderingCompatibilityVersion="4.0"/>
  </system.web>
  <system.webServer>
    <security>
      <requestFiltering>
        <requestLimits maxAllowedContentLength="2000000000" />
      </requestFiltering>
    </security>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>`

My uploading code:

 if (fuzip_file.HasFile)
                {
                    PutObjectRequest request = new PutObjectRequest();
                    Guid g = Guid.NewGuid();
                    string savepath = Server.MapPath("~/IMAGE/");
                    FileNamez = Path.GetFileName(fuzip_file.PostedFile.FileName);
                    FileNamez = "monument_zipfile_" + g.ToString() + ".zip";
                    string pathToCheck = savepath + FileNamez;
                    savepath += FileNamez;
                    FileNamez = "IMAGE/" + FileNamez;
                    fuzip_file.PostedFile.SaveAs(savepath);
                    //amazon work
                    pathToFile = savepath;
                    request.WithBucketName(BUCKET_NAME);
                    request.WithKey(FileNamez);
                    request.WithFilePath(pathToFile);
                    request.ContentType = "Appliction/zip";
                    request.Timeout = -1;
                    request.ReadWriteTimeout = 1800000;
                    client.PutObject(request);
                    S3Response response1 = client.SetACL(new SetACLRequest()
                    {
                        CannedACL = S3CannedACL.PublicReadWrite,
                        BucketName = BUCKET_NAME,
                        Key = FileNamez
                    });
                    if (File.Exists(pathToCheck))
                    {
                        File.Delete(pathToCheck);
                    }
                    cmd.Parameters.AddWithValue("@zip_file", check(FileNamez));
                    //cmd.Parameters.AddWithValue("@zip_file", "g" + id + "_English.zip");
                }

fuzip_file is fileupload control name .

KARAN
  • 1
  • 4
  • Not a good way to upload large file. Server response session is timing out. You should not increase that window. Check http://stackoverflow.com/questions/10795667/asp-net-c-sharp-outofmemoryexception-on-large-file-upload – Amit Jan 28 '15 at 12:46
  • I need an answer to upload a large not to download a large file.. – KARAN Jan 29 '15 at 06:32
  • Where did i mention about download? – Amit Jan 29 '15 at 07:12
  • when i upload file first, second,third time it runs , but after sometime it shows 404 error .....so what would be the issue kindly help me out . – KARAN Jan 29 '15 at 11:44
  • First of all your webserver is giving 404 or Amazon API? Your webserver is giving error may be because you are holding that file in memory on server while uploading. And after 3,4 upload server is becoming busy to respond. – Amit Jan 29 '15 at 12:19
  • Check this line fuzip_file.PostedFile.SaveAs(savepath); Use profiler to check memory utilization at webserver. In the first comment link check for the answer and use that. – Amit Jan 29 '15 at 12:31
  • Thank you amit, you genuinely helped me but now whats happening on uploading large file like 85mb on first time only its throwing me 404 error – KARAN Jan 30 '15 at 07:10
  • Can i contact you via email please.. – KARAN Jan 30 '15 at 07:26
  • What are the code changes you have done. Please share the same. Also you need to do async processing if you are saving file using stream. Once saving of the file completes then only start uploading to amazon api. FYI- Amazon api also support multipart uploading. Check http://architects.dzone.com/articles/amazon-s3-parallel-multipart – Amit Jan 30 '15 at 08:37

0 Answers0