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...
nishantcyno
9 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-DB
Dropbox Community Moderator
9 years agoThanks 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.
- nishantcyno9 years agoExplorer | Level 4
Hi Greg,
The official PHP SDK library I am using, works well with my personal dropbox account as I am performing test work there for my client script. Script is same for both accounts (basic and business). Otherwise same issues would encountered on my test or personal dropbox.My goal is to keep the existing file at destination and when same file will again comes with same name, it should be rename and to be place at destination with existing one. I don't want to delete the existing one as you understand through my previous post.Yes, the code is same for both environment or accounts(basic and business).I have checked on my clients localhost server directory that file downloaded as 0Byte and the same file on dropbox found in some KBs. But at my localhost I got downloaded and uploaded successfully.Ok, I will remove that sleep statements.Thanks Greg for your quick reply/support.I have to finish up these issues till end of this week. If you require to further look into that, you can have my testing and business account credentials. Let me know if you need.With Regards- Greg-DB9 years ago
Dropbox Community Moderator
Since the downloaded file itself is 0 bytes, and the remote file isn't, it appears the issue is with the download operation itself.
To continue debugging this, we should isolate the download call. For example, I just tried this based on your code, and it worked fine for me:
print_r("filename is: $filename \n");
print_r("source is: $source \n");
$ffd = fopen("./files/$filename", "wb");
$metadata = $client->getFile($source, $ffd);
print_r("Received metadata: ");
print_r($metadata);
fclose($ffd);It successfully downloaded a non-zero-byte file from a business account.
Can you try that in your client's environment and share any error or output you get?
- nishantcyno9 years agoExplorer | Level 4
Hi Greg,
Thanks for your continuous support. You have solved my downloading and uploading issue.
I have one more query regarding dropbox API.
How do I count the no. of directories inside any directory on my dropbox?
Here is my code which is not working right now.
With Regards
Nishant Sharma
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!