Skip to content

Commit

Permalink
Make sure the file to write with GridFS has a "content_type" attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
rclement committed Apr 11, 2018
1 parent a88e603 commit a5e80a1
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions flask_fs/backends/gridfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,16 @@ def read(self, filename):
return f.read()

def write(self, filename, content):
kwargs = {
'filename': filename
}

if hasattr(content, 'content_type'):
kwargs['content_type'] = content.content_type

return self.fs.put(
self.as_binary(content),
filename=filename,
content_type=content.content_type
**kwargs
)

def delete(self, filename):
Expand Down

0 comments on commit a5e80a1

Please sign in to comment.