0👍
✅
You do not need to use Blob. Just append to formData object.
Client side:
const userId = this.$store.getters['login/userId'];
const fd = new FormData();
const vue = this;
async function submitAllFiles(){
let file = vue.files[0];
fd.append('file', file);
fd.append(userId, userId);
const options = {
onUploadProgress: (progressEvent) => {
...
}
};
await vue.axios
.post('http://127.0.0.1:5000/upload_to_db', fd, options)
.then((response) => {
console.log(response);
})
Server side:
@api.route('/upload_to_db', methods=['POST'])
@cross_origin()
def upload_to_db():
user_id = request.form.get('userId')
files = request.files.getlist('file')
if insert_pdf_into_table(
user_id=user_id,
filename=files[0]):
return jsonify({'result': True})
return jsonify({'result': False})
Source:stackexchange.com