Closed sam-uraii closed 2 years ago
I guess you're not missing anything. Looks like Content-Transfer-Encoding: base64
is not supported for resumable uploads. The only solution I can think of is converting base64 to binary before uploading.
Thanks for the quick reply........ then which data type or encoding we are supposed to send or convert the data into and send it.... So that the drive will be able to play it......
Just raw binary, I guess.
okay......I am having trouble converting it to raw binary like I am using react-native-fs and it does not have an option of reading it in binary and I am unable to find a solution......(I know that you are not supposed to solve this problem but I am in real mess rn).....If you know any solution for this.........but anyways thank you very much for the help up till now.....thanks a lot
:wink: you're welcome.
There're functions atob()
and btoa()
. Some long time ago I might have had some issues with them or with one of them in RN... I don't remember.
There's also toByteArray()
from base64-js
. Looks like base64-js
is always present in any RN project.
toByteArray(b64: string): Uint8Array
fromByteArray(uint8: Uint8Array): string
@RobinBobin Thank you so much. your pointer worked and I was able to achieve what I wanted to...Thanks a lot....
but there was one more thing that I had to do, so for people who might encounter the same thing -----> toByteArray(b64: string): Uint8Array returns a object and you can't send this object as data so for that you have to run ->
let unit8Object = toByteArray(chunk);
let arrayBuffer = [];
for (let i = 0; i < unit8Object.byteLength; i++) {
arrayBuffer.push(unit8Object[i]);
}
AGAIN: Thanks a lot @RobinBobin ......
Array.from(toByteArray(chunk))
😮😮😮 ohhhh! yes definitely, this will also work......
I uploaded a 35 MB video through resumableUploader, and the upload was successful(it was a chunked upload). Now the problem is when I go and play the video in drive, the drive says that the video is unplayable.
I am sending the data in base64 encoding.(<--this is the reason).
When we do multipart upload we call isBase64() and bcoz of this the multipart upload adds --> Content-Transfer-Encoding: base64 to the body.
but when I use isBase64() function in resumableUploader nothing happens. resumableUploader extends Uploader but doesn't add Content-Transfer-Encoding: base64 anywhere....
is there anything I am missing????
PS: to prove that the data which is uploaded is raw base64 I checked the size of the file uploaded and it was 45 MB.(as we all know at time of base64 encoding the size increases by around 33%)...