Skip to content

Commit

Permalink
Fix asset store uploads with no file type
Browse files Browse the repository at this point in the history
  • Loading branch information
biilmann committed Sep 5, 2017
1 parent 30aa880 commit d644303
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/integrations/providers/assetStore/implementation.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default class AssetStore {
throw 'The AssetStore integration needs the getSignedFormURL in the integration configuration.';
}
this.getToken = getToken;

this.shouldConfirmUpload = config.get('shouldConfirmUpload', false);
this.getSignedFormURL = config.get('getSignedFormURL');
}
Expand Down Expand Up @@ -69,9 +69,11 @@ export default class AssetStore {
upload(file, privateUpload = false) {
const fileData = {
name: file.name,
size: file.size,
content_type: file.type,
size: file.size
};
if (file.type) {
fileData.content_type = file.type;
}

if (privateUpload) {
fileData.visibility = 'private';
Expand All @@ -91,7 +93,7 @@ export default class AssetStore {
const formFields = response.form.fields;
const assetID = response.asset.id;
const assetURL = response.asset.url;

const formData = new FormData();
Object.keys(formFields).forEach(key => formData.append(key, formFields[key]));
formData.append('file', file, file.name);
Expand All @@ -100,11 +102,10 @@ export default class AssetStore {
method: 'POST',
body: formData,
})
.then(() => {
.then(() => {
if (this.shouldConfirmUpload) this.confirmRequest(assetID);
return { success: true, assetURL };
});
});
}
}

0 comments on commit d644303

Please sign in to comment.