We're making changes to the Community, so you may have received some notifications - thanks for your patience and welcome back. Learn more here.

Forum Discussion

Nicolas Lavertu's avatar
Nicolas Lavertu
New member | Level 2
12 months 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);
}

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

    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.

5,875 PostsLatest Activity: 2 hours ago
325 Following

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 or Facebook.

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!