Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dropbox backend fails with "backslash not allowed" error since get_available_name method is not overrided #137

Closed
epetxepe opened this issue Apr 7, 2016 · 2 comments
Labels

Comments

@epetxepe
Copy link

epetxepe commented Apr 7, 2016

Hi all,

I'm using django version 1.9, python 2.7.

I've set up dropbox backend and configured the Oauth token. I'm using django-storages for a FileField of my model.

I'm getting:

ErrorResponse: [400] {u'path': u"Invalid path '/biocloud\\b2ce86b5-dffb-4752-b7c3-c9c27d9d40fd\\18.jpg': character at index 9: backslash not allowed"} 

I've tried to convert the paths at django model level, but it gets converted back when django starts the saving process.

I'm using S3 backend as an alternative, so I've done some debugging on how django actually executes both.

S3 backend for django-storages overrides get_available_name, and does the backslash => slash conversion.

dropbox for django-storages does not override get_available_name and the default django method, appends some alphanumeric if already exists or truncates path if it is > max_length. So no conversion is performed. And return force_text(name.replace('', '/')) at the end of django's storage.py save() is only applied to return a name to be saved in the model, but not to be send to the dropbox storage backend logic for the overrided "_save ()" function.

Right now I've overcome this issue by adding "name = name.replace ('','/')" at the beginning of dropbox backend "_save ()" function but I don't think is the best option and I think that get_available_name should be overrided in the dropbox backend.

Regards,

Gorka

@jschneier
Copy link
Owner

Hi and thanks for the report! Would you be interested in creating a pull request to fix this issue?

epetxepe added a commit to epetxepe/django-storages that referenced this issue Apr 12, 2016
- jschneier#137 I've placed everything on the _save function given that "get_available_name" was not being called when file is written with open () method.
- jschneier#138 No file_overwrite variable is considered. Overwrite is forced, if the file has the same content, dropbox keeps the previous one so no overwrite is reflected.
@jschneier
Copy link
Owner

I think this is fixed by e52a127.

XaviTorello added a commit to XaviTorello/django-storages that referenced this issue Sep 18, 2019
It could seems redundant because can it be tested at L138, but if the files path definition at jschneier#137 changes this behaviour will not be asserted.

Implicit is better than explicit :)
jschneier pushed a commit that referenced this issue Jan 6, 2020
* Return empty string if path=/ and no filename is requested

Fix #761 Dropbox base path / should be an empty string

* Convert / -> '' at the end of the join

To ensure that joined paths results are correctly handled

* Validate that root path string is converted to an empty string

It could seems redundant because can it be tested at L138, but if the files path definition at #137 changes this behaviour will not be asserted.

Implicit is better than explicit :)

* Just patch `listdir` to avoid breaking the API
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants