cordova-plugin-background-upload icon indicating copy to clipboard operation
cordova-plugin-background-upload copied to clipboard

Upload directly on S3 (putObject)

Open rudyZanotti opened this issue 3 years ago • 9 comments

Hello,

I am currently trying to upload a video directly to S3 with a signed url retrieved just before ant the put object method. The video arrives on the S3 bucket concerned, however it arrives corrupted. Indeed when I open the file here is the beginning of its content.

--Boundary+FA062E4EAF6B2732
Content-Disposition: form-data; name="file"; filename="cpcp_video_A997CCE8.mp4"
Content-Type: application/octet-stream

rudyZanotti avatar Mar 02 '22 10:03 rudyZanotti

We just released a new version this morning. Can you try it ?

ombr avatar Mar 07 '22 16:03 ombr

it doesn't seem to work :'(

Here is the error message: The request signature we calculated does not match the signature you provided. Check your key and signing method

Now even adding requestMethod: PUT in the payload does not seem to change the send method which remains a POST. And if I change it in the hard code I'm in the same situation as with the previous version

rudyZanotti avatar Mar 08 '22 08:03 rudyZanotti

Hello @rudyZanotti,

Are you latest version? Also try to remove the requestMethod from JS code.

Regards, Zafir.

zfir avatar Mar 08 '22 08:03 zfir

Hello @zafirskthelifehacker

This is my package.json : "cordova-plugin-background-upload": "github:spoonconsulting/cordova-plugin-background-upload#4.0.0",

And package.json plugin : "name": "@spoonconsulting/cordova-plugin-background-upload", "version": "4.0.0",

I see that in the FileUploader.m (iOS) line 131 it says "POST" in hard while I want to do a PUT on my S3

rudyZanotti avatar Mar 08 '22 08:03 rudyZanotti

Hello @rudyZanotti,

Make sure in your package.json, the config is like this: "@spoonconsulting/cordova-plugin-background-upload": "4.0.0"

And yes, we don't have requestMethod in the payload, try to modify FileUploader.m to cater for PUT method.

Regards, Zafir.

zfir avatar Mar 08 '22 09:03 zfir

Yes i have the latest version.

Even if I change FileUploader.m to use the PUT method, I get the same result as my first post (beginning of issue)

rudyZanotti avatar Mar 08 '22 09:03 rudyZanotti

Hello @rudyZanotti,

Try to include "Content-Decomposition": "............." in your headers.

Also you should check this guide as I think you might have to use Multipart uploads on S3: https://docs.aws.amazon.com/AmazonS3/latest/userguide/mpuoverview.html

Regards, Zafir.

zfir avatar Mar 08 '22 10:03 zfir

Made a Fork here: https://www.npmjs.com/package/cordova-plugin-background-upload-put-s3

maxcodefaster avatar May 23 '22 07:05 maxcodefaster

Hello @maxcodefaster,

Can you do a PR on this repository? We will review and merge it here. Also you can make pass the method request as a parameter so that it is configurable.

Regards, Zafir

zfir avatar May 23 '22 07:05 zfir