|
@@ -148,17 +148,33 @@ module.exports = class AwsS3 extends Plugin {
|
|
|
}
|
|
|
|
|
|
install () {
|
|
|
+ const { log } = this.uppy
|
|
|
this.uppy.addPreProcessor(this.prepareUpload)
|
|
|
|
|
|
+ let warnedSuccessActionStatus = false
|
|
|
this.uppy.use(XHRUpload, {
|
|
|
fieldName: 'file',
|
|
|
responseUrlFieldName: 'location',
|
|
|
timeout: this.opts.timeout,
|
|
|
limit: this.opts.limit,
|
|
|
+ // Get the response data from a successful XMLHttpRequest instance.
|
|
|
+ // `content` is the S3 response as a string.
|
|
|
+ // `xhr` is the XMLHttpRequest instance.
|
|
|
getResponseData (content, xhr) {
|
|
|
+ const opts = this
|
|
|
+
|
|
|
// If no response, we've hopefully done a PUT request to the file
|
|
|
// in the bucket on its full URL.
|
|
|
if (!isXml(xhr)) {
|
|
|
+ if (opts.method.toUpperCase() === 'POST') {
|
|
|
+ if (!warnedSuccessActionStatus) {
|
|
|
+ log('[AwsS3] No response data found, make sure to set the success_action_status AWS SDK option to 201. See https://uppy.io/docs/aws-s3/#POST-Uploads', 'warning')
|
|
|
+ warnedSuccessActionStatus = true
|
|
|
+ }
|
|
|
+ // The responseURL won't contain the object key. Give up.
|
|
|
+ return { location: null }
|
|
|
+ }
|
|
|
+
|
|
|
// Trim the query string because it's going to be a bunch of presign
|
|
|
// parameters for a PUT request—doing a GET request with those will
|
|
|
// always result in an error
|
|
@@ -192,6 +208,10 @@ module.exports = class AwsS3 extends Plugin {
|
|
|
etag: getValue('ETag')
|
|
|
}
|
|
|
},
|
|
|
+
|
|
|
+ // Get the error data from a failed XMLHttpRequest instance.
|
|
|
+ // `content` is the S3 response as a string.
|
|
|
+ // `xhr` is the XMLHttpRequest instance.
|
|
|
getResponseError (content, xhr) {
|
|
|
// If no response, we don't have a specific error message, use the default.
|
|
|
if (!isXml(xhr)) {
|