Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const s3 = new aws.S3();
- const s3Params = {
- Bucket: bucket,
- Key: fileName,
- Expires: 60,
- ContentType: 'image/jpeg',
- ACL: 'public-read'
- };
- return s3.getSignedUrl('putObject', s3Params);
- var file = {
- uri: game.pictureToSubmitUri,
- type: 'image/jpeg',
- name: 'image.jpg',
- };
- const xhr = new XMLHttpRequest();
- var body = new FormData();
- body.append('file', file);
- xhr.open('PUT', signedRequest);
- xhr.onreadystatechange = () => {
- if(xhr.readyState === 4){
- if(xhr.status === 200){
- alert('Posted!');
- }
- else{
- alert('Could not upload file.');
- }
- }
- };
- xhr.send(body);
- <Code>SignatureDoesNotMatch</Code>
- <Message>
- The request signature we calculated does not match the signature you provided. Check your key and signing method.
- </Message>
- function uploadFile(file, signedRequest, url) {
- const xhr = new XMLHttpRequest();
- xhr.open('PUT', signedRequest);
- xhr.onreadystatechange = function() {
- if (xhr.readyState === 4) {
- if(xhr.status === 200) {
- alert(url);
- } else {
- alert('Could not upload file.');
- }
- }
- };
- xhr.send(file);
- };
- import RNFetchBlob from 'rn-fetch-blob'
- const preSignedURL = 'pre-signed url'
- const pathToImage = '/path/to/image.jpg' // without file:// scheme at the beginning
- const headers = {}
- RNFetchBlob.fetch('PUT', preSignedURL, headers, RNFetchBlob.wrap(pathToImage))
Add Comment
Please, Sign In to add comment