Improvements for DownloadHandler
Closed this issue · 0 comments
mattiagiupponi commented
As a follow-up of this issue #11296 we want to introduce a new set of improvement for the download handler.
This improvements will help to make room for an API that supports multiple downloads (in the future)
Datasets
- Rename
DownloadHandler
toDatasetDownloadHandler
, and move it under thelayers
module - The
DatasetDownloadHandler
implements anis_ajax_safe
method which will return a boolean -> whether thedownload_url
can be called with AJAX or not. For the default handler it will be:true
forWPS
false
for all the other cases
- Remove the logic for the creation of the "original" Link entries here.
- Dataset.download_url will just return
build_absolute_uri
. The logic of whether to return any "original" Link (created manually or received from previous DBs) will be moved to theDatasetDownloadHandler
.
Documents
- Also, documents must return whether AJAX is safe or not. I wouldn't bother too much here, since we have a convoluted download / link / href logic for documents. Maybe we can implement a
Document.download_is_ajax_safe
property returningtrue
if the resource is LOCAL,false
otherwise.
API
- Implement a
download_urls
array property for theResourceBaseSerializer
with the following structure:
"download_urls": [
{
"URL": .... ,
"ajax_safe": true|false,
"default":true|false
},
]
- For the moment
download_urls
will contain only one entry;- For datasets, it will be populated with the properties obtained from the single
DatasetDownloadHandler
. NOTICE that for REMOTE resources (e.g. services)download_urls
should return an empty array. Let's think if it will be the serializer to handle this case, or letDatasetDownloadHandler
return the download_url object itself (which would beNone
for REMOTE datasets). - For documents, it will be populated from
Document.download_url
andDocument.download_is_ajax_safe
- For the other resource types it will return an empty array
- For datasets, it will be populated with the properties obtained from the single
- Deprecate the
download_url
field.