Reshma
Reshma

Reputation: 199

Dropbox File Uploading

While uploading a file to my dropbox folder via API I get a response like this:

(
  [error_summary] => path/conflict/file/..
    [error] => Array
    (
        [.tag] => path
        [reason] => Array
            (
                [.tag] => conflict
                [conflict] => Array
                    (
                        [.tag] => file
                    )

            )

        [upload_session_id] => AAAAAAAAMDWI9yGIglA8Lg
    )

   )

Can anyone suggest me a solution?

Is this response is due to already a file with this name is there in the dropbox folder?or code issue?

This is my code for file uploading,

    $cheaders = array('Authorization: Bearer '.$dptoken,
              'Content-Type: application/octet-stream',
              'Dropbox-API-Arg:'.$query);


   $ch = curl_init('https://content.dropboxapi.com/2/files/upload');
   curl_setopt($ch, CURLOPT_HTTPHEADER, $cheaders);
   curl_setopt($ch, CURLOPT_PUT, true);
   curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
   curl_setopt($ch, CURLOPT_INFILE, $fp);
   curl_setopt($ch, CURLOPT_INFILESIZE, $size);
   curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
   $response = curl_exec($ch);
   $droplist  = json_decode($response,true);

Upvotes: 0

Views: 983

Answers (1)

Greg
Greg

Reputation: 16930

You can look up the meaning of these errors in the Dropbox API v2 HTTP endpoint documentation.

For example, for /2/files/upload, clicking through to expand path/conflict/file:

There's a file in the way.

So, that is indicating that the upload failed because there is already a file at the specified path. Read the WriteMode documentation above that for more information on how to handle these scenarios.

Upvotes: 1

Related Questions