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

not working for s3 #14

Open
skyride99 opened this issue Jan 23, 2016 · 5 comments
Open

not working for s3 #14

skyride99 opened this issue Jan 23, 2016 · 5 comments

Comments

@skyride99
Copy link

Using RN 17. Below is the code.

var obj = {
uploadUrl: 'http://makeuroffer.s3.amazonaws.com',
method: 'POST', // default 'POST',support 'POST' and 'PUT'
headers: {
//'contentType': 'image/jpeg',
'Accept': 'application/json',
},
fields: {
"acl": "public-read" ,
"Content-Type": "image/" ,
"key": 'biz/' + 'third.jpg' ,
"x-amz-meta-tag": '' ,
"x-amz-meta-uuid": "14365123651274",
"bucket": 'makeuroffer' ,
"x-amz-algorithm": "AWS4-HMAC-SHA256" ,
"x-amz-credential": data.key + "/" + moment().format('YYYYMMDD') + "/" + 'us-west-2' + "/" + 's3' +"/aws4_request" ,
"x-amz-date": data['x-amz-date'] , //'20160112T105326Z'
"policy": data.policy,
"x-amz-signature": data['x-amz-signature']
},
files: [
{
//name: 'filename', // optional, if none then filename is used instead
filename: 'more.jpg', // require, file name
filepath: pic.uri, // require, file absoluete path
//filetype: 'audio/x-m4a', // options, if none, will get mimetype from filepath extension
},
]
};

FileUpload.upload(obj, function(err, result) {
  debugger;
  console.log('upload:', err, result);
});
@skyride99
Copy link
Author

The err is "Error happened: Bad Request"
The android pic.uri is "file:///storage/emulated/0/Pictures/14974007-a01b-42b1-b4b5-dc63e9eff61f.jpg"

@timsuchanek
Copy link

Hi @skyride99 , please try my answer here: #17 and report how it works

@skyride99
Copy link
Author

Yes that is the fix it needs to be 'file'.

@timsuchanek
Copy link

Yeah, and the two pull requests contain both the solution ;)

@rreusser
Copy link

I had a lot of trouble getting our S3 uploads to work (the usual vague FORBIDDEN error). I eventually added the option to disable multipart uploads and just use a signed request (i.e. PUT instead of POST). It seemed somewhat simpler and was in line with what we were doing otherwise. It's a little rough (must include fields and files keys even though not used) but see: https://github.com/rreusser/react-native-fileupload

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

3 participants