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

Improving azure storage #45

Merged
merged 4 commits into from Sep 8, 2015

Conversation

Projects
None yet
6 participants
@erlingbo
Copy link
Contributor

erlingbo commented Apr 19, 2015

No description provided.

erlingbo added some commits Apr 19, 2015

Returning absolute url from azure storage
Using MEDIA_URL from settings as newer versions of django
default storage does.

@erlingbo erlingbo force-pushed the erlingbo:master branch from bdbae7d to 277c6d1 Apr 20, 2015

@@ -57,9 +57,20 @@ def size(self, name):
return properties["content-length"]

def _save(self, name, content):
if hasattr(content.file, 'content_type'):

This comment has been minimized.

Copy link
@jschneier

jschneier Apr 27, 2015

Owner

This assumes we have a ContentFile right? I know that's what we return from _open but is this going to be the case generally?

This comment has been minimized.

Copy link
@erlingbo

erlingbo Apr 28, 2015

Author Contributor

As i have interpreted the Django docs[1] a custom storage should handle File objects [2]. Thus it should always have a file attribute. This code checks whether the file has a content_type, if not it tries to guess it.

Please correct me if I have not interpreted the docs correctly ;)

[1] https://docs.djangoproject.com/en/1.8/howto/custom-file-storage/
[2] https://docs.djangoproject.com/en/1.8/ref/files/file/

This comment has been minimized.

Copy link
@jschneier

jschneier Apr 30, 2015

Owner

You are correct, sorry about that.

@jschneier

This comment has been minimized.

Copy link
Owner

jschneier commented Apr 27, 2015

Thanks for your contribution! I've left one concern of mine in line but looks nice other than that.

if hasattr(content.file, 'content_type'):
content_type = content.file.content_type
else:
content_type = mimetypes.guess_type(name)[0]

This comment has been minimized.

Copy link
@tbartelmess

tbartelmess May 10, 2015

I think you forgot to import mimetypes

This comment has been minimized.

Copy link
@erlingbo

erlingbo May 19, 2015

Author Contributor

Nice spot. I'll fix :)

@ppawiggers

This comment has been minimized.

Copy link

ppawiggers commented Jul 3, 2015

Can someone merge this pull request?

@Hanan-Natan

This comment has been minimized.

Copy link

Hanan-Natan commented Jul 20, 2015

Merge please.

@cveilleux

This comment has been minimized.

Copy link

cveilleux commented Aug 25, 2015

+1

@ppawiggers

This comment has been minimized.

Copy link

ppawiggers commented Sep 7, 2015

Anyone with write access who can merge this?

jschneier added a commit that referenced this pull request Sep 8, 2015

Merge pull request #45 from erlingbo/master
Improving azure storage

@jschneier jschneier merged commit fa952a6 into jschneier:master Sep 8, 2015

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@jschneier

This comment has been minimized.

Copy link
Owner

jschneier commented Sep 8, 2015

Sorry for the delay folks, I have merged this. I realize that Azure storage probably wasn't really usable without that url fix in particular.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.