Closed cmalpeli closed 7 years ago
Hi @cmalpeli, thanks for the question.
Metadata is not currently implemented in the Ruby SDK, but is slated for the next release. Until then, you can achieve what you want by doing the following:
require 'filestack'
client = FilestackClient.new('YOUR_API_KEY')
filelink = client.upload(filepath: 'FILEPATH')
metadata_url = "#{filelink.url}/metadata"
metadata = Unirest.get(metadata_url).body
puts metadata
If you have files that are already uploaded, then:
require 'filestack'
filelink = FilestackFilelink.new('HANDLE', apikey: 'YOUR_API_KEY')
metadata_url = "#{filelink.url}/metadata"
metadata = Unirest.get(metadata_url).body
puts metadata
Thanks @staturecrane! It seems to be missing some fields though. This is the response I would expect which would match the JS API:
{"filename":"pingdom report.pdf","handle":"HANDLE","mimetype":"application/pdf","originalPath":"pingdom report.pdf","size":61737,"source":"local_file_system","url":"https://cdn.filestackcontent.com/HANDLE","status":"Stored"}
vs
{"mimetype"=>"application/pdf", "uploaded"=>1502136855901.77, "size"=>61737, "writeable"=>true, "filename"=>"pingdom report.pdf"}
so source, url, status are missing?
@cmalpeli It seems that the JS SDK returns different metadata from our REST API, which is what the Ruby SDK wraps. I can look into this for you more, but I cannot find any documentation to retrieve the data you are looking for from our API directly. It seems to be something specific to our Javascript implementation. Our documentation shows the different kinds of query parameters you specify.
The url and filehandle can be retrieved through a filelink:
url = filelink.url
handle = filelink.handle
For other metadata that is missing between the JS and Ruby SDKs, I will have to speak my colleagues to find out if there is a way to expose those in different implementations.
@cmalpeli I just wanted to update you and let you know that with newest release of the Ruby SDK, you can call filelink.metadata()
to get back the standard metadata from our API. This won't solve your issue with the missing information from the Picker, but the shape of that data is specific to the Picker and not part of the design of the SDKs. I can pass that along a feature request, though.
When you upload a file you get back essentially something like this:
#<FilestackFilelink:0x007faf141202a8 @handle="12345", @apikey="XXXXX", @security=nil>
Is there the ability to then get that file metadata?
Essentially need to get back something like this:
{"filename":"blah.doc","handle":"12345","mimetype":"application/msword","originalPath":"somefile.doc","size":62976,"source":"local_file_system","url":"https://cdn.filestackcontent.com/12345,"status":"Stored"}