Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upload directly on S3 (putObject) #189

Open
rudyZanotti opened this issue Mar 2, 2022 · 9 comments
Open

Upload directly on S3 (putObject) #189

rudyZanotti opened this issue Mar 2, 2022 · 9 comments

Comments

@rudyZanotti
Copy link

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

����ftypqt  ����qt  ����wide�$Õ;mdat�–�����-–F9�Çà��_ÃÁäªLv0�21
“ÂMâá˛!ÔE&pêóß#f±+y��Éåëö[��	X≤�=-ôvW9�úùöWD˘Fπ(ÙHdg�ª©'ùöAuÂ⁄§Òzry$c’�Ø<Å™ë%ˇwÎzr„Ÿ)�'�r	¡âë¨�ƒI

The latter seems to have recorded headers making it unreadable. This is my payload :

startUpload FileTransferBackground27120308 ["options": [{
    fileKey ="video";
    filePath = "/var/mobile/Containers/Data/Application/8345F1FC-B31D-44CE-B624-5D51D5173CEC/Library/Caches/cpcp_video_A997CCE8.mp4";
    headers =     {
        "Content-Type" = "video/mp4";
        "x-amz-acl" = private;
    };
    id = "be7bece4-dac4-46bd-898e-017df69733d1";
    notificationTitle = "Uploading files";
    parameters =     {
    };
    requestMethod = PUT;
    serverUrl = serverUrl;
}]]

I am on iOS and this is my package.json versions :

  • "cordova-plugin-background-upload": "git+https://github.com/spoonconsulting/cordova-plugin-background-upload.git#3.0.3",
    
  • "@capacitor/ios": "^3.4.1",
    
  • "@ionic/angular": "^6.0.1",
    

I hope you can help me 💯

@ombr
Copy link
Collaborator

ombr commented Mar 7, 2022

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

@rudyZanotti
Copy link
Author

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

@zfir
Copy link
Member

zfir commented Mar 8, 2022

Hello @rudyZanotti,

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

Regards,
Zafir.

@rudyZanotti
Copy link
Author

Hello @zafirskthelifehacker

This is my package.json :
"cordova-plugin-background-upload": "github:#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

@zfir
Copy link
Member

zfir commented Mar 8, 2022

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.

@rudyZanotti
Copy link
Author

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)

@zfir
Copy link
Member

zfir commented Mar 8, 2022

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.

@maxcodefaster
Copy link

@zfir
Copy link
Member

zfir commented May 23, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants