You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.

Forum Discussion

EconoSist's avatar
EconoSist
Explorer | Level 3
5 years ago

API V2 Upload File size above 300MB

I was using Upload v2 API in PHP by curl, but the file limit is around 300MB, when i try to upload a larger file than that, it fails.

Reading forums, docs, i found a useful thing. Use Sessions Upload.

But im stuck in this method because i cant found documentation ou samples for using that.

On my function of upload_session start i pass my token, and the file name i want to upload, and it returns the session id correctly. Now i need make the upload sessions append right?

Below is my code to use append, i make some print to show filesize and the response, but my response is printing NULL all the time, im stuck in this a few days and cant make it goes, someone can help me?

 

 

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Staff rankDropbox Staff

    Yes, as you found, since the /2/files/upload endpoint only officially supports uploading files up to 150 MB in size, you should use "upload sessions" to upload larger files. You can find the documentation for the upload session endpoints here:

    We don't offer an official PHP SDK or PHP code samples, but the documentation there includes curl examples you can translate for your language and HTTP client. There's also a Java code sample using upload sessions here. That's written for the Java SDK, but the logic should still be useful as an example.

    Anyway, you're correct that after you "start" the upload session, the next step is to "append" more data to it. Note that the /2/files/upload_session/append_v2 endpoint doesn't actually have a return value. That is, if the call succeeds, it doesn't return any other information.

    You should first check the returned status code (which appears to be '$http_code' in your code.) If it responds with a 200 status code, it means that the operation succeeded. (It would respond with a non-200 status code, optionally with a more specific error in the response body, depending on the type of failure, if it failed.)

    • EconoSist's avatar
      EconoSist
      Explorer | Level 3

      I know that you dont offer an offical SDK for PHP.

      In the "Start" i have to send the file too? i have to split my file in smalls parts? What i have to do? Where i split my file? i have to call append multiple times?

      Yes my HTTP code returns 200.

      • Greg-DB's avatar
        Greg-DB
        Icon for Dropbox Staff rankDropbox Staff

        Yes, the upload session endpoints allow you to upload a large file by sending it in multiple pieces. (Each piece can be up to 150 MB in size, but something smaller, such as 8 MB, is recommended.) You should send the pieces in order, and you can optionally send them to any of the three endpoints. That is, you can include the first piece of data with the start request, but you are not required to. You can make as many additional calls to the append endpoint as is necessary to upload the entire file. I recommend checking this example to see the flow.

        Anyway, if you're getting a 200 status code, that means that the call succeeded and whatever data you sent was appended to the upload session. (I don't actually see where you're setting the data in your code though. It looks like you're just sending an empty string via 'CURLOPT_POSTFIELDS', so you'll need to update that to send the chunk of the file.)