Answers for "axios file upload"

4

axios file upload

const formData = new FormData();
const imagefile = document.querySelector('#file');
formData.append("image", imagefile.files[0]);
axios.post('upload_file', formData, {
    headers: {
      'Content-Type': 'multipart/form-data'
    }
})
Posted by: Guest on May-15-2020
2

axios file upload

Add the file to a formData object, and set the Content-Type header to multipart/form-data.

var formData = new FormData();
var imagefile = document.querySelector('#file');
formData.append("image", imagefile.files[0]);
axios.post('upload_file', formData, {
    headers: {
      'Content-Type': 'multipart/form-data'
    }
})
Posted by: Guest on May-14-2020
1

upload a file to s3 axios

var aws = require('aws-sdk');

aws.config.update({
    accessKeyId: AWS_ACCESS_KEY
    secretAccessKey: AWS_SECRET_KEY
});

exports = module.exports = {
    sign: function(filename, filetype) {
        var s3 = new aws.S3();

        var params = {
            Bucket: SOME_BUCKET,
            Key: filename,
            Expires: 60,
            ContentType: filetype
        };

        s3.getSignedUrl(‘putObject’, params, function(err, data) {
            if (err) {
                console.log(err);
                return err;
            } else {
                return data;
            }
        });
    }
};
Posted by: Guest on December-01-2020
0

axios file upload

let fileData = new FormData();
            fileData.append("FileKey", myFile);

            let config = { headers: {
                    'Content-Type': 'multipart/form-data'
                }}
            let url = '/fileUp';

            axios.post(url, fileData,config)
                .then(function(response){

                })
                .catch(function(error){

                });
Posted by: Guest on June-24-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language