Selaa lähdekoodia

Send file as binary rather than in base64

sbkwgh 7 vuotta sitten
vanhempi
commit
c1f005261d
1 muutettua tiedostoa jossa 10 lisäystä ja 3 poistoa
  1. 10 3
      frontend/src/components/routes/SettingsGeneral.vue

+ 10 - 3
frontend/src/components/routes/SettingsGeneral.vue

@@ -135,6 +135,7 @@
 					showRemoveProfilePictureModal: false,
 					dragging: false,
 					dataURL: null,
+					file: null,
 					loading: false
 				}
 			}
@@ -163,9 +164,14 @@
 			uploadProfilePicture () {
 				this.picture.loading = true
 
+				let formData = new FormData()
+				formData.append('picture', this.picture.file)
+
 				this.axios
-					.post('/api/v1/user/' + this.$store.state.username + '/picture', {
-						picture: this.picture.dataURL
+					.post('/api/v1/user/' + this.$store.state.username + '/picture', formData, {
+						headers: {
+							'Content-Type': 'multipart/form-data'
+						}
 					})
 					.then(res => {
 						this.hideProflePictureModal()
@@ -215,9 +221,10 @@
 			},
 			processImage (file) {
 				let reader = new FileReader()
-
 				reader.readAsDataURL(file)
 
+				this.picture.file = file
+
 				reader.addEventListener('load', () => {
 					this.picture.dataURL = reader.result
 				})