Revert: Resize images before upload in web UI to reduce bandwidth
Closes: https://git.pleroma.social/pleroma/mastofe/issues/22 (Can also fix an issue with canvas and the Tor Browser)
This commit is contained in:
parent
9d23fd789d
commit
e365d3f3f2
1 changed files with 15 additions and 15 deletions
|
@ -5,7 +5,6 @@ import { search as emojiSearch } from 'flavours/glitch/util/emoji/emoji_mart_sea
|
|||
import { useEmoji } from './emojis';
|
||||
import { tagHistory } from 'flavours/glitch/util/settings';
|
||||
import { recoverHashtags } from 'flavours/glitch/util/hashtag';
|
||||
import resizeImage from 'flavours/glitch/util/resize_image';
|
||||
import { importFetchedAccounts } from './importer';
|
||||
import { updateTimeline } from './timelines';
|
||||
import { showAlertForError } from './alerts';
|
||||
|
@ -244,22 +243,23 @@ export function uploadCompose(files) {
|
|||
|
||||
dispatch(uploadComposeRequest());
|
||||
|
||||
for (const [i, f] of Array.from(files).entries()) {
|
||||
if (media.size + i > 3) break;
|
||||
for (const [i, file] of Array.from(files).entries()) {
|
||||
// Looks useless or should reuse uploadLimit
|
||||
// if (media.size + i > 3) break;
|
||||
|
||||
resizeImage(f).then(file => {
|
||||
const data = new FormData();
|
||||
data.append('file', file);
|
||||
// Account for disparity in size of original image and resized data
|
||||
total += file.size - f.size;
|
||||
const data = new FormData();
|
||||
data.append('file', file);
|
||||
|
||||
return api(getState).post('/api/v1/media', data, {
|
||||
onUploadProgress: function({ loaded }){
|
||||
progress[i] = loaded;
|
||||
dispatch(uploadComposeProgress(progress.reduce((a, v) => a + v, 0), total));
|
||||
},
|
||||
}).then(({ data }) => dispatch(uploadComposeSuccess(data, f)));
|
||||
}).catch(error => dispatch(uploadComposeFail(error)));
|
||||
api(getState).post('/api/v1/media', data, {
|
||||
onUploadProgress: function({ loaded }){
|
||||
progress[i] = loaded;
|
||||
dispatch(uploadComposeProgress(progress.reduce((a, v) => a + v, 0), total));
|
||||
},
|
||||
}).then(function (response) {
|
||||
dispatch(uploadComposeSuccess(response.data, file));
|
||||
}).catch(function (error) {
|
||||
dispatch(uploadComposeFail(error));
|
||||
});
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue