If I make a call to Storage.get, such as the code snippet below, and test.txt doesn't exist in the S3 bucket, 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.
Which versions of Amplify, and which browser / OS are affected by this issue? Did this work in previous versions?
0.4.6 in Chrome on OSX
That is correct. 404 is a file not found http error code which is correctly returned.
@mlabieniec The 404 makes sense. Returning an URL doesn't. Should it not return null if there is no such file in the bucket?
Alternatively, how can I test whether a file exists before calling Storage.get()? Thanks.
@benevolentprof you can use Storage.list() to get all the keys under a specified path and then you can check whether the file is among those keys.
Most helpful comment
@mlabieniec The 404 makes sense. Returning an URL doesn't. Should it not return null if there is no such file in the bucket?
Alternatively, how can I test whether a file exists before calling Storage.get()? Thanks.