how to configure server to make link open not download at client - server-side-scripting

ok i was reading/watching or something few days ago and came across this trick. Which said that it tells browser to not prompt to download but instead open it or try to.
I forgot where i read about it or what it told.
I just know it was about url or headers.

You have to set http header called Content-Disposition to attachment or inline.
"content-disposition" : "inline;filename=somefile.ext")

Related

Google Drive API Console: Error saving Drive UI integration page

I have a webapp in production that interacts with Google Drive through Google Drive API.
I need to change some settings in Drive interaction but I can't save.
When I save the Drive UI integration page, I receive this error:
There's a problem at our end.
Please try again. If the problem persists, please let us know using
the "Send feedback" link below. Thanks!
(spying Network console: there is an Internal Server Error in a POST call)
I tried to send feedback for months: nobody answers and the bug is still there.
I tried also to create another project: I can save the first time but then the bug returns.
How can I do? Has someone the same problem?
Is there a way to receive a reply from Google? Is there some workaround?
Thank you.
i think that problem must be Client ID
before adding Client ID, go to the Credentials -> OAuth 2.0 Client IDs
then select edit your Client ID. after that your production site url add to Authorized JavaScript origins and Authorized redirect URIs.
then enter your Client ID in Drive UI integration page
For myself trying to get the Drive UI configured I noticed a couple of errors (that don't have any specific error messages)
When adding in an Open URL it has to be a valid domain, so for instance I tried to test it out with local host, to no avail. However something like https://devbox.app.com worked, but something like https://localhost:8888 does not. Even though https://localhost is a valid javascript origin in the client_id configuration (at least for the app I am working on, not sure about other apps), localhost doesn't work as an open URL.
When adding in the mimeTypes it needs to be in the format */* and can include custom mimeTypes like application/custom+xml and application/custom-name+json not sure for other custom types that are not in a particular format like xml or json. Also not sure about wildcards.
When adding in file extensions do not add in the '.' just the name of the file extension.
The app icon I found only failed to upload the image when the image wasn't the exact dimensions, I actually ended up editing some icons in photoshop to change the pixel x pixel values as a quick work around during dev.
That worked for me to get it to save and I tested it with a file that had a custom mimeType (application/custom-name+xml specifically) and custom file extension!

Downloading file with Express

I'm using Express and I need to download a file from server. I can easily download it with just , but there is some query parameters, that I want to hide from user.
So now I'm trying to use jQuery.ajax that sending a request to Express (srv1) and then Express sending request with my parameters to the another server (srv2). Server responds me with 'Content-disposition' header and a file data. It's ok. And there is a question - can I use that file and respond with it to my initial ajax request?
The problem is, that even res.download() with files (that already on my srv1) doesn't work. Express sets headers well, but no file is prompting to download. Maybe there is a probem in ajax?
You cannot cause the browser to perform a file download with a javascript ajax request (this is a security limitation). See https://stackoverflow.com/a/9970672/266795 for details. You'll need a normal browser GET or POST request to get a proper file save dialog.

ruby/bash: How do I download a large file with using the "If-Range" and "Range" headers?

I've been trying to use mechanize to download mp3 files, but the server always returns a 404.
Looking at the headers my browser sends (checked on Chrome and FF), I noticed that the If-Range and Range headers are used to initiate a successful download, so I'm guessing the server is rejecting any request that doesn't specify them.
What is the right way to download files in this way, using ruby (Net::HTTP) or bash (curl or wget)?
404 is file not found. Are you sure your URL is correct? If it is correct then you should be able to use wget <full url and file name> to test it.

IE8(+win7) can't download a file which contains no-cache in HTTP header

I found that specific client(win7 + IE8) can't download a file(PDF file)
which contains Cache-Control:no-cache in HTTP header;
http://www.doosan.com/doosaniv/download.do?path=product&sav=225806754671.pdf&ori=d70s-5_plus.pdf&dir=20110630
But if the header contains Cache-Control:no-cache="set-cookie, there's no problem to download.
http://www.doosan.com/doosaniv/download.do?path=product&sav=225515770296.pdf&ori=d18s-5.pdf&dir=20110630
And.. in the first situation, If I run IE8 as Administrator, got no problem to download..
(Note that I logon as Administrator in win7. It's weird..)
I fount a blog and it says SSL and no-cache. I think it's similar but different problem.
Thank you.
Thank you for posting this question. The links and examples were very helpful in solving other problems.
From the MSDN article you link to:
"if a user tries to download* a file over a HTTPS connection, any response headers that prevent caching will cause the file download process to fail."
I'm guessing that IE8 doesn't respect Cache-Control:no-cache="set-cookie" as a proper header, and thus believes there is nothing preventing cache and the download is allowed to continue.

How can I validate http response headers?

It's the first time I am doing something with headers. I am mainly concerned with Cache-Control but there may be others I will need to check as well. For example, I try to send the following header to the browser (based on tutorials I just read):
Cache-Control:private, max-age=2011-12-30 11:40:56
Google Chrome displays it this way in Network -> Headers -> Response headers, but how do I know if it's correct, that there aren't any typos, syntax errors and such? Will it really work? Will the browser behave like I want it to, or will it treat it like a gibberish (something like "unknown header/value")? I've tried sending nonsensical headers on purpose but they got displayed with the rest. Is there any Chrome tool / addon for that, or any other way? Thank you in advance!
I'm afraid you won't be able to check if the resource has been cached by proxies en route, but you can check if your browser has cached it.
While in the Network panel of Chrome DevTools, hit F5 to reload your page. You should see something like "304 Not Modified" in the status field for the resource you are treating (which means the resource has not been modified and its contents were not received from the server but rather loaded from the browser's cache.)

Resources