0👍
Try opening the file and then encoding it.. something like this..
function getPdf(){
// read text from URL location
var request = new XMLHttpRequest();
request.open('GET', 'https://storage.cloudconvert.com/xxxxx.pdf', true);
request.send(null);
request.onreadystatechange = function () {
if (request.readyState === 4 && request.status === 200) {
var type = request.getResponseHeader('Content-Type');
if (type.indexOf("pdf") !== 1) {
return request.responseText;
}
}
}
}
// Encode the String
var pdf = btoa(getPdf());
var data = new FormData();
data.append('name','file')
data.append('filename', 'amjad');
data.append('file', pdf);
data.append('saved', 'true');
data.append('type', 'pdf');
axios.post('myapiurl',data, {
headers: {
'Content-Type': 'multipart/form-data'
},
}).then(res => {
console.log(res);
})
- [Vuejs]-How to redirect on other route if condition is true in in router.js vuejs
- [Vuejs]-Access v-select selected value from method called by another element
Source:stackexchange.com