sha1 digest when uploadin a chucked files in php
AnsweredHello, everyone. I have been uploading large files using curl in php. Am using chunked upload documentation API.
<>
curl -X PUT \ https://upload.box.com/api/2.0/files/upload_sessions/F971964745A5CD0C001BBE4E58196BFD \
-H 'authorization: Bearer ACCESS_TOKEN' \
-H 'content-range: bytes 0-8388607/100000000' \
-H 'content-type: application/octet-stream' \
-H 'digest: sha=fpRyg5eVQletdZqEKaFlqwBXJzM=' \
--data-binary @/tmp/part1
>
I can read my file successfully in a while loop as follows
<>
if ($stream = fopen('python.exe', 'r')) {
// get contents using offset
/$data = stream_get_contents($stream, $chunkSize, $offset);
fclose($stream);
}
>
Here is my problem
I can get everything working but my problem is how this message digest is being implemented.
Below is how am doing it in php
<>
$sha1= sha1_file('python.exe');
$fs =filesize($sha1);
//$sha1= sha1('python.exe');
$shs ="sha=";
$b64= base64_encode($sha1);
echo $sha1_digest=$shs.$b64;
>
Now when I pass it in the curl header , am getting error
<>
{"code":"invalid_digest","message":"Digest header invalid: sha=OTQ3NTgxNjNlMDRlNzc3YWVlMmI4YjRhZmYwZDNiMDY3YjIwMTQ1OA==","request_id":"4c78cabac2ecdd1a3aa0600f3b46bc52"}
>
Please sign in to leave a comment.
Comments
1 comment