Revision 1d2af25c

b/snf-pithos-app/pithos/api/public.py
157 157
            hashmaps.append(h)
158 158
        except:
159 159
            raise faults.ItemNotFound('Object does not exist')
160

  
161
    if 'Content-Disposition' not in meta:
162
        name = v_object.rstrip('/').split('/')[-1]
163
        if not name:
164
            name = v_public
165
        meta['Content-Disposition'] = 'attachment; filename=%s' % (name,)
166

  
167 160
    return object_data_response(request, sizes, hashmaps, meta, True)
b/snf-pithos-app/pithos/api/util.py
225 225
    return content_type, meta, get_sharing(request), get_public(request)
226 226

  
227 227

  
228
def put_object_headers(response, meta, restricted=False, token=None):
228
def put_object_headers(response, meta, restricted=False, token=None,
229
                       disposition_type=None):
229 230
    response['ETag'] = meta['hash'] if not UPDATE_MD5 else meta['checksum']
230 231
    response['Content-Length'] = meta['bytes']
231 232
    response.override_serialization = True
......
255 256
        for k in ('Content-Encoding', 'Content-Disposition'):
256 257
            if k in meta:
257 258
                response[k] = smart_str(meta[k], strings_only=True)
259
    disposition_type = disposition_type if disposition_type in \
260
        ('inline', 'attachment') else None
261
    if disposition_type is not None:
262
        response['Content-Disposition'] = '%s; filename=%s' % (
263
            disposition_type, meta['name'])
258 264

  
259 265

  
260 266
def update_manifest_meta(request, v_account, meta):
......
945 951
    response = HttpResponse(wrapper, status=ret)
946 952
    put_object_headers(
947 953
        response, meta, restricted=public,
948
        token=getattr(request, 'token', None))
954
        token=getattr(request, 'token', None),
955
        disposition_type=request.GET.get('disposition-type'))
949 956
    if ret == 206:
950 957
        if len(ranges) == 1:
951 958
            offset, length = ranges[0]

Also available in: Unified diff