Results for s3/store doesn't show even with results: true parameter

Archived from the Transloadit support forum. Originally posted on May 8, 2014; details may be outdated, see our docs for current behavior. Original thread

Hi guys,

I was wondering if there’s a way to have the metadata (similar to s3/import) for the object for s3/store available from the results when using results:true ?

Currently it doesn’t show even though I use results:true
It will also validate if the headers i set for s3 is successful

John

Hey John,

the /s3/store robot (or other store robots) do not emit results. Instead, they just change the URL of the files in the steps that were piped into them.

So if you have an /image/resize step, the result URL to an image would be http://tmp.transloadit.com/… If you pipe that into an /s3/store robot, the URL will be http://yourbucket.s3.amazonaws.com/… in the result JSON of your /image/resize step.

Kind regards,
Tim

Co-Founder Transloadit
@tim_kos

Also please keep in mind that the parameter is named “result” and not “results”.

Hi Tim,

Do you have a suggestion to get the metadata of the final file stored using s3/store?

This is because I could run multiple processing steps. As the result returned is a hash, I would not be able to depend on the ordering by checking the last element.

For me the simplest solution is to load that meta in s3/store step instead of storing the entire step sequence ..

Any good suggestions?

John

Hey John,

I am not sure I fully understand. Can you please attach an assembly id?

Kind regards,
Tim

Co-Founder Transloadit
@tim_kos

An moot example would be REDACTED

{
  "steps": {
    "import": {
      "robot": "/s3/import"
    },
    "convert-thumbnail_photo": {
      "width": 200,
      "height": 200,
      "resize_strategy": "crop",
      "robot": "/image/resize"
    },
    "convert-thumbnail_smaller_photo": {
      "width": 100,
      "height": 100,
      "resize_strategy": "crop",
      "robot": "/image/resize"
    },
    "convert-thumbnail_smallest_photo": {
      "width": 50,
      "height": 50,
      "resize_strategy": "crop",
      "robot": "/image/resize"
    },
    "store-thumbnail": {
      "result": true,
      "robot": "/s3/store"
    }
  }

As robot conversion steps could get complicated (eg filters, downsampling etc)
I’m only interested in the file-metadata of the final stored file … (steps inbetween are secondary)

Returned results is a hash. (hence unordered)
I would like to access it using the final store step
result[“store-thumbnail”] instead of remembering the last step run “convert-thumbnail_smallest_photo” because its dynamic. Only the final step is fixed as “store-thumbnail”

Hi John,

Thanks for the explanation. I think first of all, you should really use the use parameter. For instance:

{
  "steps": {
    "import": {
      "robot": "/s3/import"
    },
    "convert-thumbnail_photo": {
      "use": "import",
      "width": 200,
      "height": 200,
      "resize_strategy": "crop",
      "robot": "/image/resize"
      "result": true,
    },
    "convert-thumbnail_smaller_photo": {
      "use": "import",
      "width": 100,
      "height": 100,
      "resize_strategy": "crop",
      "robot": "/image/resize"
      "result": true,
    },
    "convert-thumbnail_smallest_photo": {
      "use": "import",
      "width": 50,
      "height": 50,
      "resize_strategy": "crop",
      "robot": "/image/resize"
      "result": true,
    },
    "store-thumbnail": {
      "use": [
        "import",
        "convert-thumbnail_photo",
        "convert-thumbnail_smaller_photo",
        "convert-thumbnail_smallest_photo",
      ],
      "robot": "/s3/store"
    }
  }

That should solve the ordering of the ‘hash’. It’s recommended you do this anyway for best results.

I think you should then also be able to access all the metadata via code such as:

  for stepName, files of response.results
    console.log files[0].meta.video_codec

Hope this helps!

Best,
Kevin

Hi Kevin,

Maybe i gave a really bad example. I meant that each step is to be chained (use previous step). And i’m only saving the final file.

A better example would be
Step 0 : S3/import
Step 1 : Watermark
Step 2 : Video Resize
Step 3 : S3/store

Programatically the each step chained are just added dynamically without being tracked..
And i only want the metadata of the
Step 0 : S3/import
and
Step 3 : S3/store

response.results returns a Unordered Hash in ruby. Its ordering isn’t reliable.

I manage to get the original file metadata through the “import” results. However I was wondering if i can get the metadata from the “export” result?

Hey John,

our store robots do not trigger results by themselves. The only thing that they do is they change the URL in the meta data of the steps that were passed into them.

So if you examine the results of the Video Resize step, it will have all the meta data, and its “url” property will point to an URL on Amazon S3.

Does this make sense? We know that this is a little confusing and we might change it in a future API version.

I hope this sheds some light into this.

Kind regards,
Tim

Co-Founder Transloadit
@tim_kos

Hi Tim,

its a little counter intuitive.. instead of modifying the metadata (url) of the previous step.
Why don’t you copy the previous metadata instead and change the url in the current s3/store step?

That way it maintains atomicity and also context

It is really confusing the way it works currently

John

Hey John,

yeah, we agree it’s confusing, especially for newcomers to Transloadit. We’ll talk to more customers about it and then may address it in future API changes.

Thank you for your feedback!

Kind regards,
Tim

Co-Founder Transloadit
@tim_kos

Agree that store should output result.

Example usecase scenario: allow to upload either image or video, use robot to process each, store gets input from either one or another,
I want to be able to parse result[:store] for the url instead or trying both result[:image] and result[:video] - which would help as I process more and more files for storage.

Hey Tima,

I am going to close this ticket for now. Feel free to reopen it by replying to it.
We’ll keep your feedback in mind as we design further API versions.

Kind regards,
Tim

Co-Founder Transloadit
@tim_kos