I'm able to download a file from S3 in a react native app with AWS Amplify backend using the storage.get function. However, not able to find where the downloaded files are stored? How can we access the downloaded files content in react native? The Amplify documentation doesn't say where are the files downloaded by default.
Answering my own question. Storage.get has an option to set download to true to download the files. However, I was not able to find the location of the downloaded files. Hence, I switched to getting the signed url first with storage.get by setting download to false and the use the axios to download the file using http get method by passing the signed url.
const signedURL = await Storage.get('test.json');
const response = await axios.get(signedURL);
console.debug('S3 data: ', response.data);
Related
I am using ibm-cos-sdk but I can able to store text files only, but I want to upload images and pdf files. Can someone help me out of that?
The IBM Cloud solution tutorial on how to apply end to end security to a cloud app features a file sharing app. The files are stored in COS, the app built using Node.js. See these lines of code for the example.
// upload to COS
await cos.upload({
Bucket: COS_BUCKET_NAME,
Key: `${fileDetails.userId}/${fileDetails.id}/${fileDetails.name}`,
Body: fs.createReadStream(file.path),
ContentType: fileDetails.type,
}).promise();
The snippet uses the mentioned ibm-cos-sdk with the S3 interface. I have used the app and code to upload images and PDFs.
I have videos stored in a protected bucket on S3. I am able to retrieve the URLs in my React Native application using Amplify:
Storage.get(route.params.organizerVideoS3Keys, { level: "protected"})
.then((result) => {
console.log("result", result);
setOrganizerVideo(result);
})
However, when I put this url into the Expo Video component, nothing shows up. I am able to download the video onto my computer via this url (I am not able to open it, it "isn't compatible with QuickTime Player) so I think the problem is in the way I am attempting to display the video.
My question: how do I take this url and display the video in my React Native app?
some notes:
-when I download the video it is a .mov file
-as shown above, the video is in a protected level on S3
-currently I am using Expo
Thank you.
I’m trying to get Facebook Login working using the expo-facebook package (I'm using the Managed Workflow)
I created my application in the Facebook Developer Console and copied the “App ID”.
This is the code I'm using inside my React Native Expo app:
async facebookLogin() {
await Facebook.initializeAsync('26327628297297')
const response = await Facebook.logInWithReadPermissionsAsync({ permissions: ['public_profile']})
console.log(response)
}
My understanding is that while using the Expo Client App there is no need to do any extra configuration because it will be using Expo’s Facebook App ID for all API calls.
The problem is that after logging in I get this error message:
Given URL is not allowed by the Application configuration: One or more of the given URLs is not allowed by the App’s settings. To use this URL you must add a valid native platform in your App’s settings.
I also tried added “facebookScheme” to my app.json but that didnt seem to help:
"facebookScheme": "fb26327628297297",
Thanks for your time!
Actually you just have to add platform in your app settings
So here are the steps
Open https://developers.facebook.com and select your app
Settings > Basic > Add Platform
use host.expo.Exponent as bundle id
3.Now select iOS from the window and add your Bundle ID and rest of the information and click on Save changes
and that's it.
Hope it helps you .. All the best
I have written a webservice which is sending me excel file from server to download, I have a mobile Application written in React-Native and I want to download that file in my mobile application,
I tested my webservice in browser I am able to download the file, but how to do that in react-native.
My RestAPI accept some parameter in request and in return it will download the file.
I have tried rn-fetch-blob and react-native-fs but they gives are using direct path to download the image in my case my api is providing me the file.
I have search a lot but couldn't find anything related.
Can anyone help me how to implement in this in react-native.
I am using aws-sdk can I upload images without using aws amplify I'm using expo's ImagePicker module to select the image how can I put selected image from local file path to s3.
React native Fetch API should work with AWS Signed URL
You can upload any resources into your S3 without credentials or external libraries if you have signed url.