Forum Discussion

Nicolas Lavertu's avatar
Nicolas Lavertu
New member | Level 2
3 years ago

Always overwriting the files

Hi,

I have a PHP code that generates a CSV file, and then I automatically upload this CSV file to my Dropbox.

The first time I run my code, it works and sends the file to Dropbox.

If I rerun the CSV export immediately, it won't send the file to Dropbox.

If I modify my data and rerun the CSV export, it sends the file to Dropbox.

 

I assume that when it doesn't send the file, it's because no data has been modified, so the file size remains the same, and it doesn't send it?

 

I want it to send the file to Dropbox even if the file seems identical. Here's the code for my upload using the kunalvarma05-dropbox-php-sdk API:

 

function uploadFileToDropbox($localFilePath, $fileName) {
$dropbox = initializeDropbox();
$dropboxPath = DROPBOX_BASE_PATH . $fileName;
$dropboxFile = new DropboxFile($localFilePath);

$options = [
'autorename' => false,
'mode' => 'overwrite'
];

return $dropbox->upload($dropboxFile, $dropboxPath, $options);
}

2 Replies

  • Здравко's avatar
    Здравко
    Legendary | Level 20
    3 years ago

    Hi Nicolas Lavertu,

    The file always gets uploaded but if it's the same (i.e. same name, path, size, and content), it's ignored. That's it - nothing to change. In such case metadata remain the same.

    Hope this clarifies matter.

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!