func (p *processor) Process(path string, opt *bimg.Options) ([]byte, bimg.ImageType, error) { data, err := p.source.Get(path) if err != nil { return nil, 0, err } result, err := bimg.NewImage(data).Process(*opt) imgType := bimg.DetermineImageType(result) return result, imgType, errors.InternalServerErrorErr(err) }
func (s *S3) Get(path string) ([]byte, error) { b := aws.NewWriteAtBuffer(nil) _, err := s.s3.Download(b, &s3.GetObjectInput{ Bucket: aws.String(s.bucket), Key: aws.String(path), }) if err != nil { cerr := err.(awserr.Error) if cerr.Code() == "NoSuchKey" { return nil, errors.NotFound("not found") } return nil, errors.InternalServerErrorErr(err) } return b.Bytes(), nil }