mk-fg / python-onedrive

Obsolete python/cli module for MS SkyDrive/OneDrive's old API, do not use for new projects
Do What The F*ck You Want To Public License
200 stars 32 forks source link

Put doesn't work with certain filenames #50

Closed hobbldygoop closed 9 years ago

hobbldygoop commented 9 years ago

Filenames with certain characters or character combinations in them aren't uploadable. For example:

Most of them seem to work fine with the sync client or browser upload, except filenames with : in them. Is there any way upload such files?

hobbldygoop commented 9 years ago

The onedrive help thing says regarding allowed filenames:

The file name contains characters that aren't allowed. Change its name so that it doesn’t begin or end with a space, end with a period, or include any of these characters: / \ < > : * " ? |

from http://windows.microsoft.com/en-us/onedrive/upload-file-cant-faq

Based on what i've seen from the onedrive REST Api documentation I think that might be because of the PUT request with the filename in the url instead of doing a multiform POST request maybe?

mk-fg commented 9 years ago

Actual issue that I've spotted here was that error wasn't properly reported, i.e. 400 Client Error: Bad Request instead of:

request_parameter_invalid: The operation couldn't be completed because the file name, 'somefile:stuff' isn't supported. A file name must not start or end with '.', and must not contain any of the following characters: '\\', '/', ':', ';', '*', '<', '>', '|', '?'.

...which OneDrive actually returns in json response. That should be fixed now (as of 4debdf7).

PUT seem to support more filenames than POST, which was reported/tested a while back with #19, and OneDrive docs recommend using it:

Important  On platforms that support the PUT request, PUT should be used to upload files to OneDrive when possible to avoid errors that can occur when POST is used.

As you can see from the message, colons and semicolons won't ever work - just aren't allowed by OneDrive, but percent signs were a bug due to missing name escaping (when used in url), should also be fixed (in 4f94d9e).

Both fixes should be in 15.02.9 on PyPI.

Thanks for reporting.