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:
Haelwenn (lanodan) Monnier 2018-07-04 15:13:25 +02:00
parent c0a0acbb6c
commit 1797752d02
No known key found for this signature in database
GPG key ID: D5B7A8E43C997DEE

View file

@ -4,7 +4,6 @@ import { throttle } from 'lodash';
import { search as emojiSearch } from '../features/emoji/emoji_mart_search_light';
import { tagHistory } from '../settings';
import { useEmoji } from './emojis';
import resizeImage from '../utils/resize_image';
import { importFetchedAccounts } from './importer';
import { updateTimeline } from './timelines';
import { showAlertForError } from './alerts';
@ -190,14 +189,18 @@ export function uploadCompose(files) {
dispatch(uploadComposeRequest());
resizeImage(files[0]).then(file => {
const data = new FormData();
data.append('file', file);
let data = new FormData();
data.append('file', files[0]);
return api(getState).post('/api/v1/media', data, {
onUploadProgress: ({ loaded, total }) => dispatch(uploadComposeProgress(loaded, total)),
}).then(({ data }) => dispatch(uploadComposeSuccess(data)));
}).catch(error => dispatch(uploadComposeFail(error)));
api(getState).post('/api/v1/media', data, {
onUploadProgress: function (e) {
dispatch(uploadComposeProgress(e.loaded, e.total));
},
}).then(function (response) {
dispatch(uploadComposeSuccess(response.data));
}).catch(function (error) {
dispatch(uploadComposeFail(error));
});
};
};