sencha touch 从服务器下载文件
我刚刚开始使用 sencha touch 进行开发。我有一个需要满足的客户特定要求,但不确定是否可以通过 sencha 实现。
我可以从给定服务器下载 pdf 文件或任何类型的文件吗?如果是,那么我怎样才能实现这一点。
如何将文件上传到服务器?
有什么想法吗?
I have just started using sencha touch for my development. I have a specific requirements of the client which I need to fulfill but not sure if that is possible through sencha.
Can I download pdf files or any kind of files from the given server? and if yes, then how can I achieve that.
How can I upload a file to the server?
Any ideas please?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Sencha Touch 是一个客户端框架,没有文件系统的 API。也就是说,您无法将文件下载到应用程序本身。由于 ST 本质上是一个网站,因此您也可以利用服务器端的代码来处理类似的事情。
需要注意的一件事是,如果您将应用程序打包在像 PhoneGap 这样的本机包装器中,那么您可以利用它们的 API 来访问本机文件系统。我正在使用名为 pixFileDownload 的 PhoneGap 插件来执行此操作。
Sencha Touch is a client side framework with no APIs into a filesystem. That said, you can't download files to the app itself. Since ST is essentially a website, you could also utilize code on the server side to handle something like that though.
One thing to note is that if you are packaging your app in a native wrapper like PhoneGap, then yes, you can utilize their APIs to access the native file system. I'm using a PhoneGap plugin called pixFileDownload to do just that.
不正确。
如果您有 url 形式的 PDF,您可以简单地在 Sencha 容器中创建一个 iframe 并将 src 设置为 url。
如果您没有 url,而是对二进制 PDF 文件有某种访问权限,您可能需要查看 Blob api。您可以查看 https://developer.mozilla.org/en-US/docs/Using_files_from_web_applications#Example.3A_Using_object_URLs_to_display_images 了解从哪里开始。
此链接看起来也很有前途:让 Chrome 扩展程序下载文件。
如何上传文件?将 XMLHttpRequest 与 PUT 动词结合使用并发布您的文件。
当然,您需要某个地方来将其发布到。由于 sencha touch 是客户端,因此您需要在要上传到的服务器上安装一些东西。
快乐编码:-)
Not true.
If you have the PDF in the form of a url, you can simply create an iframe within a Sencha container and set the src to the url.
If you do not have an url, but rather some sort of access to the binary PDF file you may want to look into the Blob api. You can take a look at https://developer.mozilla.org/en-US/docs/Using_files_from_web_applications#Example.3A_Using_object_URLs_to_display_images to get an idea of where to start.
This link also looks promising: Making a Chrome Extension download a file.
How to upload a file? Use XMLHttpRequest with the PUT verb and post your file.
Of course you need somewhere to post it to. As sencha touch is client side, you need something installed on the server you want to upload to.
Happy coding :-)