Skip to content

Commit c47bceb

Browse files
authored
refactor: download link type (#32)
This update improves the MIME type assignment logic for the download link. The default type is set to "application/octet-stream", but if a valid MIME type is detected, it is now correctly used.
1 parent 288c3c6 commit c47bceb

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

stac_fastapi/eodag/models/stac_metadata.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545

4646
from eodag.api.product._product import EOProduct
4747
from eodag.api.product.metadata_mapping import OFFLINE_STATUS, ONLINE_STATUS, STAGING_STATUS
48-
from eodag.utils import deepcopy
48+
from eodag.utils import deepcopy, guess_file_type
4949
from stac_fastapi.eodag.config import Settings, get_settings
5050
from stac_fastapi.eodag.constants import ITEM_PROPERTIES_EXCLUDE
5151
from stac_fastapi.eodag.extensions.stac import (
@@ -325,11 +325,13 @@ def create_stac_item(
325325
if asset_proxy_url:
326326
download_link = asset_proxy_url + "/downloadLink"
327327

328+
mime_type = guess_file_type(origin_href) or "application/octet-stream"
329+
328330
feature["assets"]["downloadLink"] = {
329331
"title": "Download link",
330332
"href": download_link,
331333
# TODO: download link is not always a ZIP archive
332-
"type": "application/zip",
334+
"type": mime_type,
333335
}
334336

335337
if settings.keep_origin_url and not origin_href.startswith(tuple(settings.origin_url_blacklist)):
@@ -338,7 +340,7 @@ def create_stac_item(
338340
"title": "Origin asset link",
339341
"href": origin_href,
340342
# TODO: download link is not always a ZIP archive
341-
"type": "application/zip",
343+
"type": mime_type,
342344
},
343345
}
344346

0 commit comments

Comments
 (0)