How to convert
#javascript #ByteArray #PDF #Uint8Array #Blob #jQuery
ByteArray
to PDF
and then upload it via jQuery
?var docData = [ yourByteArray ];
var blob = new Blob([new Uint8Array(docData)], { type: 'application/pdf' });
// Now create form to upload the file
var formData = new FormData();
formData.append("file", blob);
// Let's now upload the file
$.ajax({
type: 'POST',
url: 'https://www.YOUR-UPLOAD-FILE-ENDPOINT.com/storage',
beforeSend: request => set_ajax_headers(request),
data: formData,
processData: false,
contentType: false
}).done(function(data) {
console.log('File is uploaded!');
});
NOTE:
function set_ajax_headers
is a function that sets headers on the given request.#javascript #ByteArray #PDF #Uint8Array #Blob #jQuery