Tech C**P
14 subscribers
161 photos
9 videos
59 files
304 links
مدرس و برنامه نویس پایتون و لینوکس @alirezastack
Download Telegram
How to convert 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