content-disposition

How to set 'Content-Disposition' and 'Filename' when using FileSystemResource to force a file download file?

∥☆過路亽.° 提交于 2019-12-03 05:38:26
问题 What is the most appropriate, and standard, way to set the Content-Disposition=attachment and filename=xyz.zip using Spring 3 FileSystemResource ? The action looks like : @ResponseBody @RequestMapping(value = "/action/{abcd}/{efgh}", method = RequestMethod.GET, produces = "application/zip") @PreAuthorize("@authorizationService.authorizeMethod()") public FileSystemResource doAction(@PathVariable String abcd, @PathVariable String efgh) { File zipFile = service.getFile(abcd, efgh); return new

How to set 'Content-Disposition' and 'Filename' when using FileSystemResource to force a file download file?

我与影子孤独终老i 提交于 2019-12-02 18:57:40
What is the most appropriate, and standard, way to set the Content-Disposition=attachment and filename=xyz.zip using Spring 3 FileSystemResource ? The action looks like : @ResponseBody @RequestMapping(value = "/action/{abcd}/{efgh}", method = RequestMethod.GET, produces = "application/zip") @PreAuthorize("@authorizationService.authorizeMethod()") public FileSystemResource doAction(@PathVariable String abcd, @PathVariable String efgh) { File zipFile = service.getFile(abcd, efgh); return new FileSystemResource(zipFile); } Although the file is a zip file so the browser always downloads the file,

Linked image is not displayed in Internet explorer

蹲街弑〆低调 提交于 2019-12-02 08:11:43
I am facing a problem where linking of an image is working in all the browsers except internet explorer. I am suspecting a problem with the content disposition header value sent by the server. The server sends content disposition as attachment which instructs the browser to download the file . Now if i try to link the url with img tag , it gets rendered in all the browsers except IE. Sample is stored here https://www.w3schools.com/code/tryit.asp?filename=G180IFYZL1IS Best Regards, Saurav 来源: https://stackoverflow.com/questions/54708491/linked-image-is-not-displayed-in-internet-explorer

Prompt user to save on download from Dropbox

我的梦境 提交于 2019-12-02 07:11:01
I want to have a link to download a file from Dropbox that prompts the user instead of displaying the file in the browser. This probably requires setting a content-disposition header to 'attachment'. I'm currently using the dropbox media URL as described here: https://www.dropbox.com/developers/reference/api#media It seems my alternative might be to create a proxy, but I'd obviously like to avoid that. Is there a way to get this behavior from a direct Dropbox link? Found the answer myself. As documented here: https://www.dropbox.com/help/201 just add dl=1 to the URL. 来源: https://stackoverflow

Edge browser appears to discard response payload

五迷三道 提交于 2019-12-02 03:30:51
I have a web app that returns a PDF to the browser, which works fine in Chrome and Firefox, however it does not work in Edge (version 38.14393.0.0). The response header looks like this: Access-Control-Allow-Headers: Content-Type, Authorization Access-Control-Allow-Origin: * Cache-Control: no-store, no-cache, must-revalidate Content-Disposition: inline; filename="Invoice.PDF" Content-Length: 9255 Content-Type: application/pdf Date: Mon, 30 Jan 2017 04:38:25 GMT Pragma: no-cache Server: Microsoft-IIS/10.0 I've seen other questions suggesting that 2 requests are sent from Edge, one of which

Get filename from Content-Disposition [closed]

大憨熊 提交于 2019-12-01 18:20:26
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? If you uploaded the file using JavaEE 6 with HttpServletRequest.getPart : Part part = request.getPart("xxx"); // input type=file name=xxx String disposition = part.getHeader("Content-Disposition"); String fileName = disposition.replaceFirst("(?i)^.*filename=\"?([^\"]+)\"?.*$", "$1"); See Part . As @Marc mentioned I did not treat URL encoding. (He also made the quotes around the filename optional.

files served with content-disposition: inline still sometimes prompt for download

你。 提交于 2019-12-01 17:35:34
问题 My subject line says most of what I'm asking. I've got a web site that outputs reports in various formats (HTML, CSV, TSV, Excel, etc). Whenever possible, I'd like these files to be shown in the browser. To that end, I've set up my headers so that "Content-Disposition" is "inline". This works very inconsistently with different file types. It seems that in both FF3 and IE7, HTML will always open inline automatically. That makes sense. If I use TSV, both browsers will prompt for download, since

Get filename from Content-Disposition [closed]

僤鯓⒐⒋嵵緔 提交于 2019-12-01 17:31:00
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 5 years ago . 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? 回答1: If you uploaded the file using JavaEE 6 with HttpServletRequest.getPart : Part part = request

Python Flask downloading a file returns 0 bytes

不羁的心 提交于 2019-12-01 05:45:54
Here is the code my flask server is running: from flask import Flask, make_response import os app = Flask(__name__) @app.route("/") def index(): return str(os.listdir(".")) @app.route("/<file_name>") def getFile(file_name): response = make_response() response.headers["Content-Disposition"] = ""\ "attachment; filename=%s" % file_name return response if __name__ == "__main__": app.debug = True app.run("0.0.0.0", port = 6969) If the user goes to the site, it prints the files in the directory. However if you go to site:6969/filename it should download the file. However I am doing something wrong

Get excel file (.xlsx) from server response in ajax

醉酒当歌 提交于 2019-11-30 20:58:55
I have got a problem with getting excel file and opening download window in the browser after getting a response (in success ajax method) with that file. I have got appropriate Content-Type and Content-Disposition headers , I tried using Blob in js and I couldn't achieve what I want - simple file downloading. I accomplished few versions of my ajax, one of them is below. I developed ajax which returns excel file which I couldn't open properly because it's corrupted (despite .xlsx extension). Maybe the problem is with inappropriate data type used in Blob constructor? I tried using "xhr.response"