Tapping into core/download?

Questions related to developing on the Tonido Platform
User avatar
facelessuser
Tonido MVP
Tonido MVP
Posts: 504
Joined: Sun Sep 05, 2010 6:21 pm

Tapping into core/download?

Postby facelessuser » Sat Dec 18, 2010 2:15 pm

Okay. So I was a little annoyed with initiating downloads via php because I have to read in the whole file before serving it up. This limits downloading large files.

So I realized with some snooping that I can initiate a download via

http://name.tonidoid.com/core/downloadfile?filepath=<path to file>&filename=<file>

This is great. I can load this up in a hidden iframe and start a download.

I do have some questions though. Files with certain mime types (like pictures and text files) do not initiate as downloads. This is probably due to the mime type being populated in the header as image and text respectively. Could a hook be provided that populates the header for all files as 'application/force-download' or whatever to allow for downloading all files? I don't know if this hook is really placed here for exploitation by 3rd party apps or not, but it appears useful. I guess I could always just load a new page like you guys do. It would probably be cleaner than doing iframes like I do with uploads.

Also, is there an upload hook that is/could be provided? This would get past my major frustration with PHP. This would allow developers to hook into the server directly for file uploads and downloads without page timeouts.

User avatar
madhan
Admin Tonidoid
Admin Tonidoid
Posts: 8578
Joined: Tue Dec 30, 2008 12:13 am
Location: Dallas, USA
Contact:

Re: Tapping into core/download?

Postby madhan » Sat Dec 18, 2010 4:51 pm

All HTTP APIs you see used by Tonido can be used by PHP apps themselves, including uploads and downloads.

You can use firebug to see the APIs in firefox and use them in PHP if you want.
These APIs are pretty much stable and won't change underneath in the future.

Regarding images and some formats appearing in browser, it is probably the http content disposition setting set to inline. I would suggest you using it as is for now and then we can add these as enhancements going forward.

User avatar
madhan
Admin Tonidoid
Admin Tonidoid
Posts: 8578
Joined: Tue Dec 30, 2008 12:13 am
Location: Dallas, USA
Contact:

Re: Tapping into core/download?

Postby madhan » Sat Dec 18, 2010 4:55 pm

In fact, we have wanted to write a PHP wrapper reusable library for all the HTTP API's supported by Tonido. We never got around to it.

For example, there are a lot of APIs in Tonido which return values in easy to parse XML. The PHP wrapper could parse the XML and make it ready to use.

User avatar
facelessuser
Tonido MVP
Tonido MVP
Posts: 504
Joined: Sun Sep 05, 2010 6:21 pm

Re: Tapping into core/download?

Postby facelessuser » Sat Dec 18, 2010 6:22 pm

Cool. I will take a look into figuring out the API. Is there documentation on it? I can eventually figure it out by snooping with firebug and such, but it would be nice if it was documented. Maybe I will start writing my own PHP layer to handle it (I'll have to see how much of it I want to tap into write now to see if it is worth while). I don't mind the extra work if it works better. :D

User avatar
facelessuser
Tonido MVP
Tonido MVP
Posts: 504
Joined: Sun Sep 05, 2010 6:21 pm

Re: Tapping into core/download?

Postby facelessuser » Sun Dec 19, 2010 1:06 am

HTTP API worked great for uploads and downloads.

User avatar
madhan
Admin Tonidoid
Admin Tonidoid
Posts: 8578
Joined: Tue Dec 30, 2008 12:13 am
Location: Dallas, USA
Contact:

Re: Tapping into core/download?

Postby madhan » Sun Dec 19, 2010 8:40 am

Please see
http://www.tonido.com/developer/sdk/doc ... tpapi.html

for some HTTP API. There are much more than this available, but not all documented.
Anything you see the UI do, there is API for it.

As much as possible wrap these APIs by your calls so that if the APIs change (if ever) it only affects a small part of your code.

User avatar
facelessuser
Tonido MVP
Tonido MVP
Posts: 504
Joined: Sun Sep 05, 2010 6:21 pm

Re: Tapping into core/download?

Postby facelessuser » Sun Dec 19, 2010 11:10 am

Thanks. I found that document not long after I asked. It will be nice when the API is fully documented.

Yeah, wrappers are sound advice. Abstracting code always saves time when things change on you.

spartacus
Super Tonidoid
Super Tonidoid
Posts: 34
Joined: Wed Oct 20, 2010 1:39 pm

Re: Tapping into core/download?

Postby spartacus » Thu Nov 10, 2011 5:04 pm

Hi;

I'm using Flash, connecting to my Tonido plug. So far, the docs have been great and I can authenticate and download things including images and music.

But... the upload doc is missing from the API. Thanks to this thread, I did find it, but can't seem to make it work.

I'm connecting to the plug on my internal network.

I'm using Flash File.upload() (using a file object obtained from the browse dialog) with the request:
http://192.168.2.145/upload (URLMethod=POST)
and variables:
appname=explorer,
path=/media/usb0 (URIEncoded),
expandzip=0

In response, I get an html page (from WebsharePro) that says the share name is invalid (not XML)

What am I missing?

Regards,

User avatar
facelessuser
Tonido MVP
Tonido MVP
Posts: 504
Joined: Sun Sep 05, 2010 6:21 pm

Re: Tapping into core/download?

Postby facelessuser » Thu Nov 10, 2011 6:54 pm

Upload is actually part of Tonido explorer, you could also use PHP upload, but for the API upload:

Code: Select all

Host/upload?appname=explorer&path=file_path&expandzip=(0 or 1)

spartacus
Super Tonidoid
Super Tonidoid
Posts: 34
Joined: Wed Oct 20, 2010 1:39 pm

Re: Tapping into core/download?

Postby spartacus » Fri Nov 11, 2011 11:21 am

Thanks for responding.

Turns out that Flash ignores the

Code: Select all

contentType
for some requests (including upload) so no parameters were being sent.


Return to “Tonido Platform Development”

Who is online

Users browsing this forum: Bing [Bot] and 1 guest