That I would like to convert into a byte array.
I get the file with <v-file-input>
and this is the input of it.
I would like to convert it on the client side, then send it to the backend to be uploaded to the sql server.
I've tried to search it on google for hours.
Asked
Active
Viewed 4,245 times
0

mszabolcs
- 67
- 1
- 10
1 Answers
1
Try to add this file object to FormData and send it to nodejs. On a server side you can use multer to decode multipart formdata to req.file for instance
on a client side:
const formData = new FormData()
formData.append('file', file)
const { data: result } = await axios.post(`/api/upload-image`, formData)
on a server side:
const multer = require('multer')
const upload = multer()
...
router.post('/upload-image', upload.single('file'), uploadImageFile)
...
uploadImageFile(req, res) {
// multer writes decoded file content to req.file
const byteContent = req.file
res.end()
}

Anatoly
- 20,799
- 3
- 28
- 42
-
I would like to convert it into byte array on the client side, then just send it to the backend which upload to a sql server – mszabolcs Apr 19 '20 at 12:10
-
Then look at this answer: https://stackoverflow.com/a/32556944/1376618 – Anatoly Apr 19 '20 at 13:02