fix image upload
This commit is contained in:
parent
fde9babce5
commit
573a331bca
1 changed files with 11 additions and 2 deletions
|
@ -80,8 +80,17 @@ const store = new Vuex.Store({
|
||||||
commit('updateItem', data);
|
commit('updateItem', data);
|
||||||
},
|
},
|
||||||
async postItem({ commit, getters }, item) {
|
async postItem({ commit, getters }, item) {
|
||||||
console.log('Image data URL is at', item.dataImage); // todo: use image data URI in the request somehow
|
let blob = await fetch(item.dataImage).then(res => res.blob());
|
||||||
const { data } = await axios.post(`/1/${getters.getEventSlug}/item`, item);
|
let file = new File([blob], 'dot.png', blob);
|
||||||
|
delete item.dataImage;
|
||||||
|
item.image = file;
|
||||||
|
var formData = new FormData();
|
||||||
|
for ( var key in item ) formData.append(key, item[key]);
|
||||||
|
const { data } = await axios.post(`/1/${getters.getEventSlug}/item`, formData, {
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'multipart/form-data'
|
||||||
|
}
|
||||||
|
});
|
||||||
console.log(data); // todo: maybe preprocess item data?
|
console.log(data); // todo: maybe preprocess item data?
|
||||||
commit('appendItem', data);
|
commit('appendItem', data);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue