From: Radoslaw Zarzynski Date: Wed, 2 Mar 2016 22:40:38 +0000 (+0100) Subject: rgw: TempURL of Swift URL does support Content-Disposition override. X-Git-Tag: v10.1.0~163^2~6 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=a2d58fc1e98f23e61b7254bef725ff57ecb6188b;p=ceph.git rgw: TempURL of Swift URL does support Content-Disposition override. Signed-off-by: Radoslaw Zarzynski --- diff --git a/src/rgw/rgw_swift.cc b/src/rgw/rgw_swift.cc index 4e8c00989651..92b0c3844ac4 100644 --- a/src/rgw/rgw_swift.cc +++ b/src/rgw/rgw_swift.cc @@ -515,6 +515,25 @@ int RGWSwift::validate_keystone_token(RGWRados *store, const string& token, stru return 0; } +static void temp_url_make_content_disp(req_state * const s) +{ + bool inline_exists = false; + string filename = s->info.args.get("filename"); + + s->info.args.get("inline", &inline_exists); + if (inline_exists) { + s->content_disp.override = "inline"; + } else if (!filename.empty()) { + string fenc; + url_encode(filename, fenc); + s->content_disp.override = "attachment; filename=\"" + fenc + "\""; + } else { + string fenc; + url_encode(s->object.name, fenc); + s->content_disp.fallback = "attachment; filename=\"" + fenc + "\""; + } +} + int authenticate_temp_url(RGWRados *store, req_state *s) { /* temp url requires bucket and object specified in the requets */ @@ -592,6 +611,7 @@ int authenticate_temp_url(RGWRados *store, req_state *s) if (dest_str != temp_url_sig) { dout(5) << "temp url signature mismatch: " << dest_str << " != " << temp_url_sig << dendl; } else { + temp_url_make_content_disp(s); return 0; } }