简体   繁体   English

如何将网址提供的文件(pdf / doc)转换为json / string / base64格式,而无需在本地下载?

[英]How can I convert a file (pdf/doc) served at a url into json / string / base64 format without downloading on local?

Let's say a pdf document is served at a url, ex - https://www.polyu.edu.hk/iaee/files/pdf-sample.pdf 假设pdf文件位于网址,例如-https: //www.polyu.edu.hk/iaee/files/pdf-sample.pdf

I need to run a javascript that takes the url and makes a post request to a server with the pdf file data that can be converted back to file. 我需要运行一个使用url的javascript,并使用可转换回文件的pdf文件数据向服务器发布请求。 Typical solutions for accessing files on a server location are around downloading on local first and then having the user upload it. 访问服务器位置文件的典型解决方案是先在本地下载然后由用户上传。 How can we bypass the user interference ? 我们如何绕过用户干扰? Appreciate all inputs and workarounds like using browser cache / local storage etc. 欣赏所有输入和解决方法,例如使用浏览器缓存/本地存储等。

Thanks 谢谢

This is not possible. 这是不可能的。

JavaScript executed in a browser runs on the client machine. 在浏览器中执行的JavaScript在客户端计算机上运行。 Thus any modification on a remote resource must be downloaded, modified and uploaded to the server. 因此,必须将对远程资源的任何修改下载,修改并上载到服务器。

As you already stated: using a browser cache or local storage wont help you. 正如您已经说过的:使用浏览器缓存或本地存储不会帮助您。

You have to do this modifications on server-side eg with a servlet or php. 您必须在服务器端进行此修改,例如使用servlet或php。 You will need access to the server. 您将需要访问服务器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM