markdown-viewer icon indicating copy to clipboard operation
markdown-viewer copied to clipboard

file on google drive

Open iplasma opened this issue 5 years ago • 3 comments
trafficstars

File stored on google drive can be downloaded from link like this

https://drive.google.com/uc?export=download&id=FILEID

I tried to use this for path matching

/uc?export=download&id=(.*?)$

but Chrome still prompted to download the file instead.

Any idea why?

iplasma avatar Mar 20 '20 09:03 iplasma

The Google Drive server sets specific headers to instruct the browser that the file have to be downloaded. The path matching regexp and the extension in general, only works when the browser opens up the raw markdown file in a tab.

simov avatar Mar 29 '20 15:03 simov

Yes, found out this too. With other extension, such as Modify Content-Type, I was able to view the file in browser. Another trick is that the URL above will lead to multiple redirections, this tip below is helpful as there is no redirection when export to txt.

https://learninginhand.com/blog/google-document-url-tricks

But, if this extension can handle the content-type, that will be fantastic!

iplasma avatar Mar 29 '20 18:03 iplasma

Actually the content-disposition header have to be removed.

Once you load https://drive.google.com/uc?export=download&id= the browser redirects to https://doc-00-2g-docs.googleusercontent.com/... so for that response the content-disposition have to be stripped resulting in the browser rendering the raw markdown file instead of prompting to download it. At that stage a correct path matching regexp will be able to pick it up and render it as HTML.

However I don't think such functionality like removing arbitrary headers from arbitrary sites is in the scope for this extension. Probably a combination between extension that removes headers and this one is going to work, the only question in this case is how are you going to guarantee that the extension that removes the header will be executed before the markdown viewer one.

simov avatar Mar 30 '20 10:03 simov