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