如何将图像URL上传到数据库。就像我想从数据库获取图像(url)并上传回数据库一样。
要上传图像文件,请将图像附加到formData上,但是如果图像为url,我该如何上传到数据库
功能:
export function* edit(action) {
try {
const data = action.payload;
var formData = new FormData();
formData.append('name', data.name);
formData.append('icon', data.icon); // error:icon not provided (its url of image)
const url = `${BRAND}/${data.id}`;
const response = yield call(putUtil, url, data);
if (response.status == 200) {
action.callback('success');
yield put(editBrandSuccesseAction(response.data.data));
} else if (response.status == 201) {
action.callback(response.data.message);
yield put(editBrandErrorAction(response.data.message));
}
} catch (err) {
console.log('error', err);
debugger;
}
}