Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
We currently use Dropbox's Python SDK to overwrite existing file contents with the method .files_upload(). With give it the file id as a parameter along with the file content and it works:
client.files_upload(
file_contents,
file_id,
mode=WriteMode.overwrite
)
The problem is that, if the file is a shared one, it won't work. Is it even possible?
Can you clarify what you mean when you say "it won't work"? What error/output do you get?
You should be able to use this method to upload to an existing file by specifying the file ID, even if it's in a shared folder, for instance, as long as the file is in the connected account and the account has write access.
But what if the file is stored at root? Or what if someone shared only the file and not its parent folder necessarily? I have simulated two cases. One which the file is shared with me, but it's stored at the owner's root folder. The other file is stored at a folder which I don't have access to the folder, only the file. In both cases I get the following error:
dropbox.exceptions.ApiError: ApiError('dc54baf177204ec09c535d47a46e21b2', UploadError('path', UploadWriteFailed(reason=WriteError('no_write_permission', None), upload_session_id='AAAAAAAAAkihHB-Mp2VFBg')))
The location within the account doesn't really matter, but which account it is in does matter. From your description, it sounds like the file is not in the connected account (that is, the account for the access token you're using), but rather is in another account (and the file just happens to be shared individually to the connected account).
Since the file is not actually in the connected account, the connected account does not have the ability to write to it, resulting in this 'no_write_permission' error.
You are right. The file belongs to another account, which have shared the file with the connected account. The thing is that, the connected account does write to the file if it is in a shared folder as you said. In my case, only the file is shared with the connected account, while the file's parent folder is not, so it doesn't work. Another issue is that if the file resides in the root folder of the owner, it doesn't belong to a sharable folder. So in order for the users of our App send data between shared files, they must be in a shared folder as well.
Hi there!
If you need more help you can view your support options (expected response time for a 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!