-
-
Notifications
You must be signed in to change notification settings - Fork 866
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
S3BotoStorage fails when keys contain ":" #248
Comments
Indeed. According to Amazon's Docs the colon (":") should probably be url-encoded. That is a bug in the library, probably we should make |
Out of curiosity how are you getting the file up to the server? If I use the normal Django fileuploader process then those characters are stripped out. |
Also, renaming a file to have |
This isn't so much of an issue in for the user uploads if it strips annoying characters then. Our use case is for a backup script that uses datetimes for the folder names to be able to prune backups later solely based on the directory names. So we are mostly using django-storages as a convenient way to reuse the storage definitions we already use. We could of course just use boto3 directly, but it would be nice if it worked directly with django-storages. So don't feel like it's too much of a priority to fix. |
Ah, makes sense. What does the actual url that amazon shows you look like in S3? My hunch is it is already urlencoded which would make this a pretty easy fix. |
Hi, sorry for late reply. Yes, the colons in the url are urlencoded. So |
Combine the identical s3boto3 and s3boto implementations of safe_join() and its tests to reduce code duplication. Fixes #248
Trying to do this:
storage.delete("2017-01-13T12:55:32.497821+00:00/somekey")
Which fails like so:
I have tracked this down to storages.backends.s3boto.safe_join's call to
urlparse.urljoin
. Having ":" confuses the join to skip the/
at the beginning offinal_path
which then fails during the check thatfinal_path
is a sub path ofbase
.It's probably a small fix, but I unfortunately don't have enough knowledge of the urlparse lib to know how to do it.
PS.
And yes, AWS supports having ":" part of the keys. Running
aws s3 rm s3://<bucket>/2017-01-13T12:55:32.497821+00:00/somekey
works fine.The text was updated successfully, but these errors were encountered: