benjreinhart / react-native-aws3

Pure JavaScript React Native library for uploading to AWS S3
MIT License
399 stars 151 forks source link

Ability to presign #33

Open sebringj opened 7 years ago

sebringj commented 7 years ago

Send networked presigned from server to avoid having to set secret and also have programatic control over user's namespace.

YousefMohsen commented 6 years ago

It would be awesome if this important feature gets implemented in the library! @sebringj ; where do I set the presigned url? in options as presigned? and have you tested it, does it work?

sebringj commented 6 years ago

@YousefMohsen hi, to get a presigned url, you can use this to get you started: https://github.com/sebringj/siggy what you do is in your code is just in time request to get this presigned one, then proceed with upload passing in presigned header. You'll have to modify this repo to inject the right headers for your security along with modifying the example code to check the header for a token or whatever security thing you are doing to ensure the user is signed in. My code is proprietary otherwise would give put up for you to use. My stuff is in production and works but doesn't do you any good, sorry but hope this gets you going.

onPress={() => getPresignedUrl()
.then(signingInfo => doUpload(signingInfo))
.then(done)}

type scenario

YousefMohsen commented 6 years ago

Im using the aws-sdk s3.getSignedUrl('putObject',params,callback) to generate presigned urls. I just cant figure out how to use that url to upload files in proper format. I tried to use axios and it uploads to the bucket, but saves the image as a json object.. Anyways thanks for your help:) and i hope to see the presigned url feature in the RNS3 library one day.

arrygoo commented 6 years ago

hey @sebringj , I made a fork of this package and merged your PR for myself. One question though. I'm seeing that you're passing signature as one of your parameters. How do you get that?

I'm using aws-sdk-js on my server to generate the signedUrl, which returns a full url including the signature. Do you strip it from there?