Amazon S3 exception: "The specified key does not exist"

I am using the AmazonS3Client in an Android app using a getObject request to download an image from my Amazon S3 bucket.

Currently, I am getting this exception:

com.amazonaws.services.s3.model.AmazonS3Exception: 
The specified key does not exist.
 (Service: Amazon S3; Status Code: 404; Error Code: NoSuchKey;

Even though I am able to see the object with the specified key in my S3 bucket.


Solution 1:

Well this error is actually rather straight forward.  it simply means that your file does not exist up within the S3 bucket.  Several things could be wrong:

  1. You could be trying to reference the wrong file.  Double check the path that you tried to retrieve.

  2. Whenever the file was uploaded it must have failed.  Check the logs for your S3Sync process to see if you can find any relevant output

Source

Solution 2:

For me, the object definitely existed and was uploaded correctly, however, its s3 url still threw the same error:

<Code>NoSuchKey</Code>
<Message>The specified key does not exist.</Message>

I found out that the reason was because my filename contained a # symbol, and I guess certain characters or symbols will also cause this error.

Removing this character and generating the new s3 url resolved my issue.

Solution 3:

Note that this may happen even if the file path is correct due to s3's eventual consistency model. Basically, there may be some latency in being able to read an object after it's written. See this documentation for more information.