0

I have this image

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.

1 Answer 1

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()
  }
Sign up to request clarification or add additional context in comments.

2 Comments

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
Then look at this answer: stackoverflow.com/a/32556944/1376618

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.