Forum Discussion

Raul S.7's avatar
Raul S.7
New member | Level 2
9 years ago

PPTX corrupted when uploading in php (chunk)

Uploading a 'pptx' file divided into parts through the Dropbox API is corrupted.
Does anyone have a solution to this problem?
Thank you

 

 

$dropboxAdapter = new DropboxStorageRepository();
$file = $request->file("file");
$chunk = (int) $request->get('chunk', false);
$chunks = (int) $request->get('chunks', false);
$originalName = $request->get('name');
$dir_move = utf8_encode ($request->headers->get("current-dir"));

if($chunk == 0){
     $id = $dropboxAdapter->client->chunkedUploadStart(File::get($file));

     session::forget("fid");
     session::forget("bof");
     Session::set("fid", $id);
     Session::set("bof", $file->getSize());
}
if($chunk > 0 && $chunk < $chunks - 1){

     $bytesOffset = Session::get("bof");
     $id = Session::get("fid");
     $dropboxAdapter->client->chunkedUploadContinue($id,$bytesOffset,File::get($file));
     Session::set("bof",$bytesOffset+$file->getSize());

}
if ($chunk == $chunks - 1) {
    $bytesOffset = Session::get("bof");
    $id = Session::get("fid");
    $dropboxAdapter->client->chunkedUploadContinue($id,$bytesOffset,File::get($file));

    $file_dropbox = $dropboxAdapter->client->chunkedUploadFinish($id,$dir_move."/".$originalName,WriteMode::force());
/
    $saveFile = $this->SaveFile($file_dropbox);
    session::forget("fid");
    session::forget("bof");
}

 

1 Reply

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    9 years ago

    It looks like you're using a third party library for connecting to the Dropbox API, so I'm afraid I can't offer much insight on that. We can't support third party libraries themselves as we didn't make them.

     

    That said, when uploading to the Dropbox API, the file type doesn't make a difference really. The Dropbox API will accept whatever raw data you give it. I suspect there's just an issue with the code you're using to make the upload calls. I recommend adding some logging or stepping through with a debugger to see where/when it's not doing what you expect. (E.g., perhaps you're missing a chunk, or the chunks or out of order, etc.) You can also inspect the uploaded file itself to get some hints. (E.g., is the uploaded file larger or smaller than expected, etc.)

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.

The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.

If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X, Facebook or Instagram.

For more info on available support options for your Dropbox plan, see this article.

If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!