Maverick
Maverick

Reputation: 2760

sencha touch to download files from server

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.

  1. Can I download pdf files or any kind of files from the given server? and if yes, then how can I achieve that.

  2. How can I upload a file to the server?

Any ideas please?

Upvotes: 0

Views: 3118

Answers (2)

Soeren L. Nielsen
Soeren L. Nielsen

Reputation: 171

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 :-)

Upvotes: 0

M69
M69

Reputation: 506

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.

Upvotes: 1

Related Questions