Does railway bucket support content type constraints when creating an upload url?
simone-samardzhiev
HOBBYOP
a month ago
I am creating an presigned upload url, to upload an image to railway s3 bucket. Here is the code snippet
func (s *S3ImageStorage) CreateUploadUrl(ctx context.Context, imageKey string, contentType domain.ImageContentType) (string, error) {
req, err := s.presignClient.PresignPutObject(ctx, &s3.PutObjectInput{
Bucket: aws.String(s.bucket),
Key: aws.String(imageKey),
ContentType: aws.String(string(contentType)),
}, func(options *s3.PresignOptions) {
options.Expires = s.urlExpiry
})
if err != nil {
return "", domain.NewError("error presigning url for image upload", domain.ErrorCodeInternal, err)
}
return req.URL, nil}
The problem is that when I send the request, I can omit the content type header, without the bucket blocking the request.
0 Replies
Status changed to Open Railway • 27 days ago
Status changed to Solved simone-samardzhiev • 27 days ago