cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
If you’ve changed your email address, now's the perfect time to update it on your Dropbox account and we’re here to help! Learn more here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

why there is no option for write mode for move/copy files

why there is no option for write mode for move/copy files

Thang2000
Explorer | Level 4

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.

2 Replies 2

Здравко
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-DB
Dropbox 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.

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropbox Staff
  • User avatar
    Здравко Legendary | Level 20
What do Dropbox user levels mean?