Handle "NotFound" error code from HeadObject (#228)

* Handle "NotFound" error code from HeadObject

This accommodates third party implementations of the S3 interface, such as Minio, that may return a different error string.

* Check NotFound error string in test

This also fixes an incorrect return value.
This commit is contained in:
Adam Jensen 2019-01-13 18:16:40 -05:00 committed by Marius
parent daa2250530
commit 204044e4b9
2 changed files with 2 additions and 4 deletions

View File

@ -364,7 +364,7 @@ func (store S3Store) GetInfo(id string) (info tusd.FileInfo, err error) {
Key: store.keyWithPrefix(uploadId + ".part"),
})
if err != nil {
if !isAwsError(err, s3.ErrCodeNoSuchKey) && !isAwsError(err, "AccessDenied") {
if !isAwsError(err, s3.ErrCodeNoSuchKey) && !isAwsError(err, "NotFound") && !isAwsError(err, "AccessDenied") {
return info, err
}

View File

@ -381,9 +381,7 @@ func TestDeclareLength(t *testing.T) {
s3obj.EXPECT().HeadObject(&s3.HeadObjectInput{
Bucket: aws.String("bucket"),
Key: aws.String("uploadId.part"),
}).Return(&s3.HeadObjectOutput{
ContentLength: aws.Int64(0),
}, nil),
}).Return(&s3.HeadObjectOutput{}, awserr.New("NotFound", "Not Found", nil)),
s3obj.EXPECT().PutObject(&s3.PutObjectInput{
Bucket: aws.String("bucket"),
Key: aws.String("uploadId.info"),