0

For a multitude of reasons, mostly ease of use and internally broken imports, I don't want to add AWS amplify to my current react-native project. Is there any way I can directly read objects from S3 without AWS amplify and all of the complication that comes with setting that up in an existing project?

Thanks

I've tried using the @aws-sdk/client-s3 but that imports packages from the NodeJS standard library (which are not available in react, such as 'stream'). I've tried to setup AWS amplify but it adds far too much complexity for something as simple as reading an Object from an S3 bucket

EDIT: I've had a working react native application deployed on the app store for months now, but suddenly the s3 sdk started importing the standard NodeJS library (stream). My application doesn't require any of the IAM roles, buckets, and "amplify backends" that amplify creates for me. In the interest of keeping my app's code as simple and straightforward as possible, I don't want to add a whole new managed workflow for something that I don't use

Leo A
  • 11
  • 2

2 Answers2

0

If the files in the S3 bucket are public, you can read then via simple HTTP GET. Look for the "Static Website Hosting" option in the bucket's "Properties" tab. A better route, is to access the S3 bucket via CloudFront. Just look for articles about static hosting via S3.

If the files are not all public, then you may want to hit a REST endpoint (e.g. API Gateway) which can check authorization and return a temporary signed-url (via Lambda) that points to the S3 file you want. The client app can then simply GET the file via the signed-url.

If you plan to use other AWS services it should pay-off to learn and incorporate Amplify.

Dave
  • 7,552
  • 4
  • 22
  • 26
  • I appreciate the response but that seems like it would be walking around the solution but not solving it. It's not that I don't want to learn amplify. I've had a working react native application deployed on the app store for months now, but suddenly the s3 sdk started importing the standard NodeJS library. My application doesn't require any of the IAM roles, buckets, and "amplify backends" that amplify creates for me. In the interest of keeping my app's code as simple and straightforward as possible, I don't want to add a whole new managed workflow for something that I don't use – Leo A Jun 23 '23 at 16:02
  • @LeoA Perhaps revert the `@aws-sdk/client-s3` dependency to the version it was working; then update it until the breaking change. File a bug report --- or possibly uncover the config change on your end that is causing the streaming libs to be pulled in. – Dave Jun 23 '23 at 16:11
  • What's really stumping me and what caused me post this is that I made absolutely 0 changes to my dependencies or any code related to s3. This error appeared just after finishing bug testing for a prod build so the changes happening at the time were extremely minimal. I separate my commits where I change the build # and version, so I look at all commits past the last working build's commit and there were 0 changes that interfaced with s3. Only 2 lines changed in UI components on completely different Views. I wish I could be of more help describing my situation but I am completely stumped – Leo A Jun 23 '23 at 16:15
  • My advice, and sorry if this is "duh", is to revert all code, dependency, and tooling changes. Attempt to produce a build that is identical to (bugs and all) the shipping version. It sounds like a dependency or globally installed part of your toolchain is behaving differently. Get back to a known working state at your top priority. Then methodically introduce changes until you identify the step that's causing the issue. – Dave Jun 23 '23 at 16:26
  • What I just did and it worked! I had done this before but this time I added the umbrella 'aws-sdk' package instead of just the @aws-sdk/client-s3 package and it worked! Thanks! – Leo A Jun 23 '23 at 16:28
0

Fixed!! Quite annoyed at how simple this was:

I restored my git branch to the last working point, deleted the node_modules, install aws-sdk (not @aws-sdk/client-s3 like I had before), and rebuilt my development client with expo, and voila!

Leo A
  • 11
  • 2