Questions tagged [content-disposition]

The Content-Disposition response header field is used in HTTP web responses to convey additional information about how to process a response payload. It can also be used to attach additional metadata such as a filename to the response.

The Content-Disposition response header field is used in HTTP web responses to convey additional information about how to process a response payload. It can also be used to attach additional metadata such as a filename to the response. The full definition of the content-disposition header is outlined in RFC 6266.

The content-disposition header is added to a HTTP response when further descriptive information is desired to aid the receiver in interpreting the payload. Usage follows the following grammar:

content-disposition = "Content-Disposition" ":" disposition-type *( ";" disposition-parm )

disposition-type = "inline" | "attachment" | disp-ext-type ; case-insensitive disp-ext-type = token

disposition-parm = filename-parm | disp-ext-parm

filename-parm = "filename" "=" value | "filename*" "=" ext-value

disp-ext-parm = token "=" value | ext-token "=" ext-value ext-token =

Questions related to this tag should be concerned with describing the payload of a HTTP Response. An example question may be - "Save a PDF that's been streamed to the browser"

448 questions
8
votes
4 answers

in rails, unable to override content-disposition filename

I am using Rails 3.1.0.rc8 and Chromium 15.0.874.102. I want to set the filename of a CSV download. I am following this SO solution, but find myself unable to modify the filename of the Content-Disposition header. Here is my code: module…
8
votes
1 answer

After upgrade to Rails 6: Content-Disposition header now adds strange filename*=UTF-8

I just upgraded from Rails 5 to 6. When sending some file to download to the client, I now have a different Content-Disposition: Before: attachment; filename="Report_test_name Product_test_name A4A WCAG20 Project_test_name Project_test_customer…
Joshua Muheim
  • 12,617
  • 9
  • 76
  • 152
8
votes
3 answers

Azure Blob Storage V2 does not deliver content-disposition header any more

I have a question about the "content-disposition" blob property of a file in Azure Blog Storage V2. I configured this property of my file howto-201901.pdf as "attachment; filename=howto.pdf" with Azure Storage Explorer 1.6.2 (see screenshot) asn in…
8
votes
1 answer

Include Content-disposition header for Django FileUpload

I defined an API endpoint which accepts a file (e.g. using Django REST Framework). In Django, the content disposition header can be used when inspecting the…
8
votes
1 answer

Content-disposition:inline header won't show images inline?

I'm trying to show an image inline on a page. It is being served by a codeigniter controller. class Asset extends MY_Controller { function index( $folder, $file ) { $asset = "assets/$folder/$file"; if ( !file_exists( $asset…
hamstar
  • 1,787
  • 4
  • 16
  • 23
8
votes
1 answer

Get filename from Content-Disposition

I'm uploading a blob file from an HTML form to a database using JSP. I need to insert the filename into DB. I know that the filename is stored in the Content-Disposition header, how could I get that?
h2c
  • 235
  • 1
  • 3
  • 11
7
votes
1 answer

How do you specify Content-Type Name and Content-Disposition Filename using Attachment and LinkedResource?

Emails generated using System.Net.Mail.Attachment and System.Net.Mail.LinkedResource contain MIME parts. The question is how to specify the Content-Type Name and Content-Disposition Filename values and encodings for the headers in those MIME…
Mike Green
  • 2,031
  • 2
  • 18
  • 16
7
votes
4 answers

Java webapp: adding a content-disposition header to force browsers "save as" behavior

Even though it's not part of HTTP 1.1/RFC2616 webapps that wish to force a resource to be downloaded (rather than displayed) in a browser can use the Content-Disposition header like this: Content-Disposition: attachment; filename=FILENAME Even…
SyntaxT3rr0r
  • 27,745
  • 21
  • 87
  • 120
7
votes
2 answers

Chrome adds "-, attachment" to downloaded file

I use Symfony2 Framework and use the following code to export an xml file: $response->setStatusCode(200); $response->headers->set('Content-Type', 'application/xml'); $response->headers->set('Content-Description', 'Submissions…
Micha
  • 523
  • 10
  • 26
7
votes
3 answers

AWS S3: Force File Download using 'response-content-disposition'

Few lines(below) generate signed URL to which browser is redirected to download a file from S3. I am facing well known issue of Chrome not downloading pdf files from S3 when content type is set as Octet Stream. The solution is to force chrome to…
7
votes
5 answers

IE 7 bug? - prompt save / open when downloading file - c# asp.net 3.5

I have an aspx page with linkbuttons that fire javascript to pop open a new aspx page to stream files to the browser for downloading by users. When developing and unit testing on XP SP3, IE 7 and FireFox 3.5, using the following code (key being the…
6
votes
2 answers

Get suggested filename from org.apache.http.HttpResponse

In Android, you can download a file using the org.apache.http classes HttpClient, HttpGet and HttpResponse. How can I read the suggested filename from the HTTP request? E.g. In PHP, you would do this: header('Content-Disposition: attachment;…
l33t
  • 18,692
  • 16
  • 103
  • 180
6
votes
1 answer

Can I create a one-time S3 link w/ content-disposition: attachment?

I have PDFs, images, and text files in S3. I want the ability to create a download link to the file, but only sometimes. Sometimes my users want to view files on the web, but sometimes they want to click a "download" button to grab them in a single…
Johnny 5
  • 1,521
  • 3
  • 10
  • 11
6
votes
1 answer

Forcing the inline rendering of a PDF document in Rails

I'm writing a service that generates PDF files from a set of XML files. The PDF is being correctly generated. However, everytime I click on the "view PDF" link, the browser asks the user to download the PDF file. I need the PDF to display inline,…
Fábio Batista
  • 25,002
  • 3
  • 56
  • 68
6
votes
1 answer

PHP: RFC-2231 How to encode UTF-8 String as Content-Disposition filename

Scenario: (in PHP) I have a form submission with a UTF-8 encoded string ($name) to support international characters. Upon submitting the form (via GET), I am creating a CSV download file. I want the name of the file to be that string + .csv …
1 2
3
29 30