Search code examples
amazon-s3aws-amplify

What is returned by Storage.get in AWS Amplify when the file doesn't exist?


I'm trying to use AWS Ampify and can't find a good reference. A guide, I can find, but not a reference. If I make a call to Storage.get, such as the code snippet below, and test.txt doesn't exist, what is returned?

Storage.get('test.txt')
    .then(result => console.log(result))
    .catch(err => console.log(err));

I'm finding that it returns a URL that results in a 404.


Solution

  • As of Amplify 0.4.7, the intended behaviour is to return a URL that results in a 404.

    If you want to avoid the 404, you can check for the presence of the file using Storage.list(). Or you can attempt to pre-load the URL with some exception handling, before actually use it.

    This seems like sub-optimal behaviour to me, especially with a framework like angular, so I've submitted a feature request.