fix: s3 not found should not return an error

This commit is contained in:
Mustafa Gezen 2021-09-11 03:08:24 +02:00
parent 1e769f96dd
commit 7c15c41a9f
Signed by: mustafa
GPG Key ID: DCDF010D946438C1
1 changed files with 5 additions and 1 deletions

View File

@ -23,6 +23,7 @@ package s3
import (
"bytes"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/s3"
@ -89,7 +90,10 @@ func (s *S3) Read(path string) ([]byte, error) {
Key: aws.String(path),
})
if err != nil {
return nil, err
s3err, ok := err.(awserr.Error)
if !ok || s3err.Code() != s3.ErrCodeNoSuchKey {
return nil, err
}
}
body, err := ioutil.ReadAll(obj.Body)