made file name in upload not to have spaces
This commit is contained in:
@@ -88,7 +88,7 @@ export default function UploadProduct() {
|
||||
// most importend
|
||||
imgRead.readAsDataURL(e.target.files[0]);
|
||||
}
|
||||
if (file.length) {
|
||||
if (file?.length) {
|
||||
if (file[0].name) {
|
||||
setSelectedFile(file?.[0].name);
|
||||
setImgDetails(file?.[0])
|
||||
@@ -143,7 +143,7 @@ export default function UploadProduct() {
|
||||
}
|
||||
|
||||
let reqData = { // PAYLOAD FOR API CALL
|
||||
file_name: selectedFile,
|
||||
file_name: selectedFile.replace(/ /gi, ""),
|
||||
file_size: imgDetails.size,
|
||||
file_type: imgDetails.type,
|
||||
file_data: img,
|
||||
@@ -158,6 +158,7 @@ export default function UploadProduct() {
|
||||
//API CALL TO UPLOAD COMES HERE
|
||||
setRequestStatus({loading: true, status: null, message: ''}) // SETS REQUEST LOADING TRUE
|
||||
apiCall.sendFiles(reqData).then(res=>{
|
||||
console.log('TESTING', res)
|
||||
if(res.status != 200 || res.data.internal_return < 0){
|
||||
return setRequestStatus({loading: false, status: false, message: 'Something went wrong, try again'})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user