Updated image drop handling to respect original file name

Now uses the previously timestamp gen name as a backup to the original
name. Aligns with the image manager upload which uses the original name
where given.

Closes #3470
This commit is contained in:
Dan Brown 2022-06-07 14:59:00 +01:00
parent 3f271ebecb
commit 3fe666f36a
No known key found for this signature in database
GPG Key ID: 46D9F943C24A2EF9

View File

@ -60,13 +60,7 @@ async function uploadImageFile(file, pageId) {
throw new Error(`Not an image file`);
}
let ext = 'png';
if (file.name) {
let fileNameMatches = file.name.match(/\.(.+)$/);
if (fileNameMatches.length > 1) ext = fileNameMatches[1];
}
const remoteFilename = "image-" + Date.now() + "." + ext;
const remoteFilename = file.name || `image-${Date.now()}.png`;
const formData = new FormData();
formData.append('file', file, remoteFilename);
formData.append('uploaded_to', pageId);