flask-storage 2.0.1.dev2__py3-none-any.whl → 2.0.2.dev1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
flask_storage/files.py CHANGED
@@ -77,11 +77,27 @@ def lower_extension(filename):
77
77
  return filename
78
78
 
79
79
 
80
+ #: What a file compressed as a whole is, keyed by the encodings `mimetypes` knows.
81
+ #: Brotli has no media type of its own, so a `.br` file falls back to the default.
82
+ COMPRESSED_MIMES = {
83
+ "gzip": "application/gzip",
84
+ "bzip2": "application/x-bzip2",
85
+ "xz": "application/x-xz",
86
+ "compress": "application/x-compress",
87
+ }
88
+
89
+
80
90
  def mime(filename, default=None):
81
91
  """
82
92
  A basic helper to guess mime type from a filename or url
83
93
  """
84
- return mimetypes.guess_type(filename)[0] or default
94
+ mime_type, encoding = mimetypes.guess_type(filename)
95
+ # `guess_type` describes `data.csv.gz` as `text/csv` compressed with gzip:
96
+ # the type of what is inside, not of the file itself. Served as `text/csv`,
97
+ # a proxy compressing text on the fly would compress it a second time.
98
+ if encoding:
99
+ return COMPRESSED_MIMES.get(encoding, default)
100
+ return mime_type or default
85
101
 
86
102
 
87
103
  class All:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: flask-storage
3
- Version: 2.0.1.dev2
3
+ Version: 2.0.2.dev1
4
4
  Summary: Simple and easy file storages for Flask
5
5
  Author-email: Etalab <etalab@data.gouv.fr>
6
6
  Project-URL: Home, https://github.com/etalab/flask-storage
@@ -1,6 +1,6 @@
1
1
  flask_storage/__init__.py,sha256=dodstsHJ2pgovSmfyufqKXLch6Xynm_SHr8Ky-S8Yzk,1352
2
2
  flask_storage/errors.py,sha256=aswLO-PZklMaTrnogkbvywkRAdxCmtzwUYkaRxhVC8M,832
3
- flask_storage/files.py,sha256=y8G6gev8dDfZ9IR1VbJ0AaSo2zaH8dyQ2eN-1W7EPPQ,3754
3
+ flask_storage/files.py,sha256=4OVMm1WH0YjzFCXyK67jUMfIQgQ42oQ7RjM9CvQl4xg,4424
4
4
  flask_storage/images.py,sha256=qG4j7xzNY5Ts4Vpu2058d97t_kk9h1u_z7-YDVWewzg,1879
5
5
  flask_storage/mongo.py,sha256=SukL0Bfk2rzFs5zE2VUml0fNCjSqWbSa2oTeI813OL0,9105
6
6
  flask_storage/signals.py,sha256=_FXSq5KEwlHyE4aMBwOMd6XhleYDUiLd9Ut6U5Tp6cg,180
@@ -10,9 +10,9 @@ flask_storage/backends/__init__.py,sha256=thajBIF5Ok5zAiLEZmYBHwTxjmtD6_-Y1kXnNY
10
10
  flask_storage/backends/local.py,sha256=Z0hgBtSr5yRbllGLRlqXpTHSNJgTJLTlxl0harEmAXY,4245
11
11
  flask_storage/backends/mock.py,sha256=0-b6SfzIuVO5Uu8BlSz1uNNALyBGNHePz5o79Ef1aOw,185
12
12
  flask_storage/backends/s3.py,sha256=z5L7juDiwMLOglKQvS7fqIVDkeZZcgwcGzZT9hDgE70,9626
13
- flask_storage-2.0.1.dev2.dist-info/licenses/LICENSE,sha256=Jsa1CKm-fF0guY0ht3reKgv2D3ReoCjNVX0IPtreqSE,1081
14
- flask_storage-2.0.1.dev2.dist-info/METADATA,sha256=W_XZyVBGDcg8M8MZ-ZkaswtMaOt2-x9ykobmo81tiBw,1312
15
- flask_storage-2.0.1.dev2.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
16
- flask_storage-2.0.1.dev2.dist-info/entry_points.txt,sha256=hX7fv5H16y_4DLa-TJKZrdSqcddfRo1AEFSN3oH0cHs,156
17
- flask_storage-2.0.1.dev2.dist-info/top_level.txt,sha256=dewU5rlVVfXSOtwXxhCTSujH1TX9-8SXFK9L67Lux3U,14
18
- flask_storage-2.0.1.dev2.dist-info/RECORD,,
13
+ flask_storage-2.0.2.dev1.dist-info/licenses/LICENSE,sha256=Jsa1CKm-fF0guY0ht3reKgv2D3ReoCjNVX0IPtreqSE,1081
14
+ flask_storage-2.0.2.dev1.dist-info/METADATA,sha256=FINPn-v0HfDQLHR-ApOkAQYdEg_3Jqnv_MD7HIuRbIU,1312
15
+ flask_storage-2.0.2.dev1.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
16
+ flask_storage-2.0.2.dev1.dist-info/entry_points.txt,sha256=hX7fv5H16y_4DLa-TJKZrdSqcddfRo1AEFSN3oH0cHs,156
17
+ flask_storage-2.0.2.dev1.dist-info/top_level.txt,sha256=dewU5rlVVfXSOtwXxhCTSujH1TX9-8SXFK9L67Lux3U,14
18
+ flask_storage-2.0.2.dev1.dist-info/RECORD,,