It is currently Thu Sep 18, 2014 8:41 am

All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 13 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Tapping into core/download?
PostPosted: Sat Dec 18, 2010 2:15 pm 
Tonido MVP
Tonido MVP
User avatar
Joined: Sun Sep 05, 2010 6:21 pm
Posts: 504

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.

_________________
My Tonido Plugins:


Offline
 Profile  
 Post subject: Re: Tapping into core/download?
PostPosted: Sat Dec 18, 2010 4:51 pm 
Admin Tonidoid
Admin Tonidoid
User avatar
Joined: Tue Dec 30, 2008 12:13 am
Posts: 8386
Location: Dallas, USA

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.


Offline
 Profile  
 Post subject: Re: Tapping into core/download?
PostPosted: Sat Dec 18, 2010 4:55 pm 
Admin Tonidoid
Admin Tonidoid
User avatar
Joined: Tue Dec 30, 2008 12:13 am
Posts: 8386
Location: Dallas, USA

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.


Offline
 Profile  
 Post subject: Re: Tapping into core/download?
PostPosted: Sat Dec 18, 2010 6:22 pm 
Tonido MVP
Tonido MVP
User avatar
Joined: Sun Sep 05, 2010 6:21 pm
Posts: 504

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

_________________
My Tonido Plugins:


Offline
 Profile  
 Post subject: Re: Tapping into core/download?
PostPosted: Sun Dec 19, 2010 1:06 am 
Tonido MVP
Tonido MVP
User avatar
Joined: Sun Sep 05, 2010 6:21 pm
Posts: 504

HTTP API worked great for uploads and downloads.

_________________
My Tonido Plugins:


Offline
 Profile  
 Post subject: Re: Tapping into core/download?
PostPosted: Sun Dec 19, 2010 8:40 am 
Admin Tonidoid
Admin Tonidoid
User avatar
Joined: Tue Dec 30, 2008 12:13 am
Posts: 8386
Location: Dallas, USA

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.


Offline
 Profile  
 Post subject: Re: Tapping into core/download?
PostPosted: Sun Dec 19, 2010 11:10 am 
Tonido MVP
Tonido MVP
User avatar
Joined: Sun Sep 05, 2010 6:21 pm
Posts: 504

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.

_________________
My Tonido Plugins:


Offline
 Profile  
 Post subject: Re: Tapping into core/download?
PostPosted: Thu Nov 10, 2011 5:04 pm 
Super Tonidoid
Super Tonidoid
Joined: Wed Oct 20, 2010 1:39 pm
Posts: 33

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,


Offline
 Profile  
 Post subject: Re: Tapping into core/download?
PostPosted: Thu Nov 10, 2011 6:54 pm 
Tonido MVP
Tonido MVP
User avatar
Joined: Sun Sep 05, 2010 6:21 pm
Posts: 504

Upload is actually part of Tonido explorer, you could also use PHP upload, but for the API upload:
Code:
Host/upload?appname=explorer&path=file_path&expandzip=(0 or 1)

_________________
My Tonido Plugins:


Offline
 Profile  
 Post subject: Re: Tapping into core/download?
PostPosted: Fri Nov 11, 2011 11:21 am 
Super Tonidoid
Super Tonidoid
Joined: Wed Oct 20, 2010 1:39 pm
Posts: 33

Thanks for responding.

Turns out that Flash ignores the
Code:
contentType
for some requests (including upload) so no parameters were being sent.


Offline
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 13 posts ]  Go to page 1, 2  Next

All times are UTC - 6 hours [ DST ]


 Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: