You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.
Forum Discussion
Thang2000
2 years agoExplorer | Level 4
why there is no option for write mode for move/copy files
I notice there is an option to use writemode
mode=dropbox.files.WriteMode.overwrite
when using uploading API ( dbx.files_upload() ), but there is no option for copying/moving file api. Can we add that? I'm using Python SDK:
dbx.files_move_v2()
dbx.files_copy_v2()
and have been writing many boilerplates to handle file conflicts.
Also, what is the proper way to handle this, right now I'm doing:
try:
dbx.files_copy_v2(from_path=entry.path_display, to_path=path_to_autopdf_folder)
except WriteConflictError as e:
but getting "catching classes that do not inherit from baseexception is not allowed python".
Appreciate the help.
- ЗдравкоLegendary | Level 20
Thang2000 wrote:
...
Also, what is the proper way to handle this, right now I'm doing:try: dbx.files_copy_v2(from_path=entry.path_display, to_path=path_to_autopdf_folder) except WriteConflictError as e:
but getting "catching classes that do not inherit from baseexception is not allowed python".
...Hi Thang2000,
In most programing languages not all types can be thrown (and catched, of course), but only a subset (so called throwable types). As you saw already, in Python that subset is form of types inherited from the mentioned class. That's it. Here make a note that you are trying to catch WriteConflictError class' object; a class that is regular, non throwable (i.e. not exception) class. All errors that comes from API use ApiError class as a carrier. There you can inspect what's in error field to see what's the actual error (including its type). You may put the carrier class in all similar except statements where the target is Dropbox API and once catch the error actual error type can be found out. 😉
Hope this clarifies matter to some extent.
- Greg-DBDropbox Staff
Thang2000 I'll pass this along as a feature request for support for setting the write mode when moving/copying files, but I can't promise if or when that might be implemented.
Also, you can find an example of catching an API error in the Python SDK here.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
5,910 PostsLatest Activity: 2 days agoIf 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!