forked from ckan/ckanext-archiver
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
75cd56d
commit 9442ae4
Showing
3 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from flask import Blueprint | ||
from ckan import model | ||
from ckanext.archiver.model import Archival | ||
from ckanext.cloudstorage.helpers import generate_download_signed_url_v4 | ||
import ckantoolkit as tk | ||
|
||
|
||
redirect = tk.redirect_to | ||
config = tk.config | ||
|
||
s3_archived = Blueprint("s3_archived_redirect", __name__) | ||
|
||
|
||
def s3_archived_redirect(id, resource_id, filename): | ||
|
||
q = model.Session.query(Archival).filter_by(resource_id=resource_id) | ||
filepath = model.Session.execute(q).first()[8] | ||
url = generate_download_signed_url_v4(filepath) | ||
return redirect(url) | ||
|
||
|
||
s3_archived.add_url_rule(u'/tmp/<id>/<resource_id>/<filename>', | ||
view_func=s3_archived_redirect) |