We’re Still Here to Help (Even Over the Holidays!) - find out more here.
Forum Discussion
nishantcyno
9 years agoExplorer | Level 4
File uploading and downloading in business account.
Hi Dropboxer,
I am working on dropbox api in PHP and managing file and folder through running a script from server. All things are working file only issue which I am facing is to uploading a ex...
Greg-DB
Dropbox Community Moderator
9 years agoI'll be happy to help this, but I'll need some more information. Please reply with:
- the name and version of the platform and SDK/library you are using
- the steps to reproduce the issue
- the full text of any error or output
- the relevant code snippet(s)
- the name and version of the platform and SDK/library you are using
- the steps to reproduce the issue
- the full text of any error or output
- the relevant code snippet(s)
nishantcyno
9 years agoExplorer | Level 4
Thanks,
Following the tutorials from https://www.dropbox.com/developers-v1/core/sdks/php
-I'm using Composer for your project's dependencies, I have just add dropbox-sdk to your composer.json instead of downloading the SDK.
dropbox/dropbox-sdk": "1.1.*"
-I have successfully moved files from one folder to another folder through move($sourcepath,$destpath) API function. But I have a particular case where file may already exits at destination. So I have take a file from my dropbox $sourcepath and download in my system and then upload it on destination path. By doing this existing file remain there and new file got renamed and saved to dropbox $destpath. But showing 0Byte along with file name. Below screenshot shows a simillar issue inside my client's dropbox account. File size shows 0Byte.
I have tried same with my basic Dropbox account and I am able to do it successfully. Below is the output Which I want for my client's Dropbox account.
- I am doing this by PHP script following snippet shows the my particular logic
- Greg-DB9 years ago
Dropbox Community Moderator
Apologies for the delay! I wasn't notified of your reply for some reason. Are you still having this issue?
If so, can you share your first two screenshots as links? They didn't come through in the post.- nishantcyno9 years agoExplorer | Level 4
Thanks Greg
I still have this issue, as I told you that my code(the earlier third screenshot) is working fine for this particular case where file is already in the destination location, it got renamed by placing '(1)' at end and showing 430.56KB) in my basic dropbox account. Below is my account's screenshot.
Now, the above thing is not working on my client's business dropbox account. The file got renamed but showing 0Byte meaning something is not working on business account. Below is the screenshot.
Pls tell me why this is happening with Business account and reply as soon as possible.
Thanks
Nishant Sharma
- Greg-DB9 years ago
Dropbox Community Moderator
Thanks for the additional information! I took a look over your post and code.
First, I should note that you're using the PHP SDK for API v1, which is deprecated. You should migrate to API v2 as soon as possible. We don't have an official PHP SDK for API v2, but you can use a third party library, or call the HTTPS endpoints directly.
Anyway, it sounds like the original goal was to replace a file that already exists. You're downloading and re-uploading the file to do so, but a more efficient alternative would be to just delete the existing file at the destination. That would save you the time and bandwidth for the download and upload. (We'll consider this a request for write mode options for moving files anyway though.) In the code you have though, you're using WriteMode::add, which won't overwrite the destination file. It sounds like you want WriteMode::force instead.
In any case, the type of account (e.g., basic versus business) shouldn't make any difference in the upload functionality like this. Are you definitely running the same code in both cases?
Further, in order to track down where the 0 byte file is coming from, please check the size of the local file. That way, we can determine if the upload itself is not working properly for you, or if it's the download.
If the local file is 0 bytes, please then check if the original source file on Dropbox is 0 bytes. That would indicate if there's an issue with the download call itself, or if this is working properly and the file does just happen to be 0 bytes.
Finally, I see that you have some sleep statements in your code after the download and upload calls. Those calls block, so you don't need to add any sleep. The code won't proceed until the operation is done.
About 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!