Idenfify and use different uploaded files

Hi

I’m uploading two different images using Robodog SDK (as blobs) but when I receive those files on Transloadit I don’t know how to identify each one. I tried with the “fields” property using each filename, but it doesn’t work.

“part1”: {
“robot”: “/video/encode”,
“use”: {
“steps”: [
{
“name”: “video0”,
“as”: “video”
},
{
“name”: “:original”,
“fields”: “title1.png”,
“as”: “watermark”
}
]
},
“preset”: “iphone-high”,
“ffmpeg_stack”: “v4.3.1”
},
“part2”: {
“robot”: “/video/encode”,
“use”: {
“steps”: [
{
“name”: “video5”,
“as”: “video”
},
{
“name”: “:original”,
“fields”: “title2.png”,
“as”: “watermark”
}
]
},
“preset”: “iphone-high”,
“ffmpeg_stack”: “v4.3.1”
},

Any help will be welcome

Thanks!

Hey there!,

So in order to use the “fields” property to select a specific upload from your set of uploads it’s value wouldn’t be the filename. The value would be the name of the form input.

For example if you had the following HTML form and attached Robodog to it.

<form id="upload-form" action="/uploads" enctype="multipart/form-data" method="POST">
      <input type="file" name="image_1" />
      <input type="file" name="image_2" />
      <button type="submit">Upload Images</button>
</form>

<script>
window.Robodog.form('form#upload-form', {
  params: { ... }
})
</script>

Then you would be able to separate the images within your Transloadit template using the fields operator like so:

“part1”: {
    “robot”: “/video/encode”,
    “use”: {
        “steps”: [
            {
                “name”: “video0”,
                “as”: “video”
             },
             {
                 “name”: “:original”,
                 “fields”: “image_1”,
                 “as”: “watermark”
             }
         ]
     },
     “preset”: “iphone-high”,
     “ffmpeg_stack”: “v4.3.1”
},
“part2”: {
    “robot”: “/video/encode”,
    “use”: {
        “steps”: [
             {
                 “name”: “video5”,
                 “as”: “video”
             },
             {
                 “name”: “:original”,
                 “fields”: “image_2”,
                 “as”: “watermark”
             }
         ]
    },
    “preset”: “iphone-high”,
    “ffmpeg_stack”: “v4.3.1”
},

hi

Thanks a lot for your help. I tried with this method but I don’t use form upload, I generate the image blobs on the client and upload directly through the JS plugin (and coulnd’t find a way to specify the “field” values for each image (it wasn’t the file name).

Finally I found a solution using /file/filter robot filtering each file name:

"wm1": {
  "use": ":original",
  "robot": "/file/filter",
  "accepts": [
    [
      "${file.name}",
      "==",
      "title1.png"
    ]
  ],
  "error_on_decline": false
},
"wm2": {
  "use": ":original",
  "robot": "/file/filter",
  "accepts": [
    [
      "${file.name}",
      "==",
      "title2.png"
    ]
  ],
  "error_on_decline": false
},
"part1": {
  "robot": "/video/encode",
  "use": {
    "steps": [
      {
        "name": "video1",
        "as": "video"
      },
      {
        "name": "wm1",
        "as": "watermark"
      }
    ]
  },
  "preset": "iphone-high",
  "ffmpeg_stack": "v4.3.1",
},
"part2": {
  "robot": "/video/encode",
  "use": {
    "steps": [
      {
        "name": "video2",
        "as": "video"
      },
      {
        "name": "wm2",
        "as": "watermark"
      }
    ]
  },
  "preset": "iphone-high",
  "ffmpeg_stack": "v4.3.1",
}

It worked fine for me, using each of the images as the watermark for each video.