avatar rickblalock Pro Jul 16. 2010. 10:25 pm
Just started implementing the file api and I think I'm in a brain freeze....How can I access a file via the API? The name field returns the file name (i.e. yourFile.pdf) but not the full path. The permalink is cool but doesn't allow direct access to the file. How can I access the file via the API?
avatar Ilija Studen Staff Jul 17. 2010. 4:34 am
Hello Rick,

By accessing file's permalink, you'll be able to download the file to your local storage and work with it from there. System will restore full file details, including name and proper MIME type.

Images can be accessed directly by adding disposition=inline GET variable to the URL. Note that is not officially supported, but it should work in current activeCollab version - use it at your own risk.
avatar rickblalock Pro Jul 17. 2010. 8:59 am
Thanks for the response so quickly.

When I access the permalink, it requires a login, the normal API authentication doesn't work.

Maybe I'm not understanding what you're saying entirely. For instance, if I'm trying to access a file via GET, you're saying I can do something like this?:
...api.php?path_info=projects/2/files/1516&disposition=inline...
avatar rickblalock Pro Jul 17. 2010. 9:25 am
I went in to the PM and saw how it works from there and see what you mean. So basically bypass the /api.php routing and just go right to the file. Works fine. Thanks1!
avatar rickblalock Pro Jul 17. 2010. 11:10 am
Actually....it only works if you're logged in. Which is fine for security...but I don't see a way to make it work via the RESTful api. Trying to access to the files causes me to go to the login screen.
avatar Ilija Studen Staff Jul 17. 2010. 4:15 pm
Are you including token in the URL? That should get you by the login screen.
avatar rickblalock Pro Jul 17. 2010. 4:19 pm
Yes I am. I'm making a normal RESTful call like with everything else in my app but not working with the files
avatar Ilija Studen Staff Jul 18. 2010. 3:56 am
Hello Rick,

When you use the same URL in your browser (while you are not logged in), do you get the file served?

Maybe you are not handling response correctly with your HTTP library... This is the only request that returns file data instead of XML/JSON response.
avatar rickblalock Pro Jul 19. 2010. 6:51 am
Ah I see. I wasn't entering in the token via the normal routing, only through the api.php/ path. I didn't realize you could do that. cool. thanks!
avatar Ilija Studen Staff Jul 20. 2010. 5:44 am
Hello Rick,

Glad to hear that it works ok. If you need anything else, you know where you can find us :)
or Go To Next Page