Search code examples
jqueryapifile-uploadcoldfusionuploadcare

uploadcare how to get a listing of files like a file manager


Ive just started taking a look at the uploadcare product and its api.

Ive just realized that the API only seems to allow you to upload files with no way of viewing a listing of the files once they are uploaded.

Would anyone happen to know if its possible to use the widget to retrieve a listing of files that has been uploaded ?


Solution

  • Based on mojo's answer regarding REST requiring private keys, here's a quick proof of concept of how you can do a back-end proxy in CFML:

    <cfhttp method="GET" url="https://api.uploadcare.com/files/">
        <cfhttpparam type="header" name="Accept"        value="application/vnd.uploadcare-v0.3+json" />
        <cfhttpparam type="header" name="Date"          value="Fri, 09 Feb 2013 01:08:47 -0000" />
        <cfhttpparam type="header" name="Authorization" value="Uploadcare.Simple demopublickey:demoprivatekey" />
        <cfloop index="Key" collection=#Url# >
            <cfhttpparam type="url" name=#Key# value=#Url[Key]# />
        </cfloop>
        <cfloop index="Key" collection=#Form# >
            <cfhttpparam type="formfield" name=#Key# value=#Form[Key]# />
        </cfloop>
    </cfhttp>
    
    <cfloop index="HeaderName" collection=#cfhttp.ResponseHeader# >
        <cfheader name=#HeaderName# value=#cfhttp.ResponseHeader[HeaderName]# />
    </cfloop>
    
    <cfcontent type="application/json" />
    <cfoutput>#cfhttp.FileContent#</cfoutput>
    

    Again, it's proof of concept not finalised code, but should demonstrate the idea of how you can do it.