-1

Hello I need to read a file from an external url and place it in a javascript variable so that it can be interpreted, the problem is that I can not do this through requests because I am blocked by the cross-origin access policy and I can not release the access on the server for this.

If I put this url in iframe or href link for example the file is usually downloaded because I need the contents of this file in javascript, is there any way to do this?

an example link https://docs.google.com/get_video_info?authuser=&docid=1OLSvZ13QeMqckNxJoYWlgkSAAwjIrNVFGg

user9022531
  • 107
  • 1
  • 2

3 Answers3

1

If you can't enable CORS or use "jsonp" (both require changes in the server) then you can't do it directly with the site you want, but what you can do is to create a "proxy route" in your server which will get a url parameter and make the request for you.

Leibale Eidelman
  • 2,772
  • 1
  • 17
  • 28
0

If you can do server side programming you can use curl for getting data on server side and use xhr for getting it on client side.... Thanks

vaku
  • 697
  • 8
  • 17
  • I can not touch the server but I can download with CURL the problem is that I need the user's browser to do this download – user9022531 May 01 '19 at 19:28
  • Hey, I found [this](https://mnaoumov.wordpress.com/2018/02/05/download-google-drive-file-via-ajax-ignoring-cors/) link, I didn't try it, but you can do some experiments on it... – vaku May 01 '19 at 19:37
  • this works however it ends up in the same problem as requested via CURL, docs.google.com/get_video_info returns a file that only the browser you requested has access to the video links and like the https://cors-anywhere.herokuapp.com API / request I can not view the video. – user9022531 May 01 '19 at 20:37
0

You can use ifame or build proxy route but there is a limit number of playing

You sure can force user to disable CORS or install Extension to synchronize DRIVE_STREAM cookie but it only working on PC and also got limited

So if you want to serving video with multiple resolution on Google Drive, your only solution is convert video to HLS/MPEG-DASH

John Doe
  • 36
  • 1
  • 6
  • the iframe low however I would have to ask the user to upload the file so he can watch the video, concludes that the only way is using extensions. – user9022531 May 09 '19 at 02:36