'is there any way to convert byte array to blob object on client side in node.js
Is there any way to get blob object from byte array client side without actual downloading file
Client side where I want to pass blob object =>
request.get('/api/get/video/blob/'+d1+'/'+d2+'/'+d3)
.end((err, res) => {
if (err) {
console.log("err="+err)
} else {
console.log("data="+res)
if(res)
{
var uploadVideo = new UploadVideo();
uploadVideo.uploadFile(access_token,res// need actual blob object to pass @ res); but what I get is byte array see following code
Server side=>
server.route({
method: 'GET',
path: '/api/get/video/blob/{d}/{s}/{x}',
handler: function handler(request, reply) {
const {d,s,x} = request.params;
const key = d+'/'+s+'/'+x;
var bucket = 're.render-previews';
var params = {
Bucket: bucket,
Key: key
};
s3.getObject(params, function(err, data) {
console.log("coming back");
if (err) {
console.log("err=>");
console.log(err);
// reject(err)
} else {
console.log("data=>");
console.log(data);
reply(data); // where I get byteArray
}
});
}
});
Solution 1:[1]
this line of code worked for me var blob = new Blob([new Uint8Array(BYTEARRAY)], { type: 'video/mp4' });
Solution 2:[2]
This works for me.
var blob = new Blob([new Uint8Array(BYTEARRAY).buffer], { type: 'video/mp4' });
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | user2703473 |
Solution 2 | Dat TT |