Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WebKitFormBoundary included in file payload on direct upload to s3

I have a dropzone.js instance that uploads files directly to an S3 bucket using CORS and then passes me the file information inside of javascript to use. This is the tutorial I followed for it...

The file upload itself seems to work fine, the files show up in the s3 bucket at the correct file path, however all of the files include something like this wrapped around it

------WebKitFormBoundaryMH4lrj8VmFKgt1Ar
Content-Disposition: form-data; name="files[0]"; filename="image-name.png"
Content-Type: image/png


IMAGE CONTENT HERE

------WebKitFormBoundaryMH4lrj8VmFKgt1Ar--

I cannot for the life of me figure out why this is happening. It doesn't matter what type/mime of file I upload, everything includes it.

Any help would be greatly appreciated!

like image 897
Tom Schlick Avatar asked Aug 05 '16 05:08

Tom Schlick


People also ask

What is S3 direct upload?

Updated: September 13, 2022. Amazon S3 Direct Upload for Web UI is an addon that allows Web UI to make use of S3 Direct Upload to directly upload files to a transient bucket, which will then be moved by the Nuxeo server to a final bucket once the upload is finished.

Can Lambda upload file to S3?

Nowadays, there is a growing demand for serverless architecture, which makes uploading files to AWS S3 using API gateway with AWS Lambda (NodeJs) extremely useful. By simply following the above steps, you can make your own API to upload your files to S3 buckets on AWS.


1 Answers

inside your init: function() { .. }

add the following:

      self.on("sending", function(file, xhr, formData) {
        var _send = xhr.send;
        xhr.send = function() {
          _send.call(xhr, file);
        }
      });
like image 178
Dalin Huang Avatar answered Nov 02 '22 23:11

Dalin Huang