In my Angular application I try to upload a file to AWS-S3 with $http.put(url, file)
.
However it's not working, I get back a HTTP-403 Forbidden telling me that the signature s3 calculated differs from the one I provided BUT if I make the same request with curl like curl -X PUT -T file url
then everything is ok the file gets uploaded. So either the way $http.put is working is bad (for this task) or curl has some magic. Can anyone elaborate?
When uploading a file with the $http service, it is important to set
Content-Type: undefined
.The default content type for the $http service is
application/json
. By settingContent-Type: undefined
, the $http service omits theContent-Type
header and the XHR API sets theContent-Type
header to that of the file.