How do I handle images vs non-images?

Started by eric.gay3 replies15 views
eric.gayOriginal post
#1

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

I’m a bit confused reading the doc on multi-file-type upload on how to modify this template so I can support multiple file types. I want images to be resized (working fine in the current template below), but PDF uploads to remain untouched and stored on S3.

How would I do that (without also storing the original image on S3)?

{ "steps": {
    "thumb": {
      "use": ":original",
      "robot": "/image/resize",
      "width": 100,
      "height": 100,
      "format": "png"
    },
    "export_thumb": {
      "path": "docs/${file.original_id}_th.png",
      "robot": "/s3/store",
      "key": "",
      "secret": "",
      "bucket": "vfolio"
    },
    "big": {
      "use": ":original",
      "robot": "/image/resize",
      "width": 800,
      "height": 800,
      "format": "png"
    },
    "export_big": {
      "path": "docs/${file.original_id}.png",
      "robot": "/s3/store",
      "key": "",
      "secret": "",
      "bucket": "vfolio"
    }
} }

thanks!

tim-kos
#2

Hey Eric,

right now you can’t do this without also storing the original images.

However, we have a filter robot that allows you to filter files according to some rules. It’s still in beta, but if you want to give a test drive you can find the docs here: http://transloadit.com/docs/file-filter Let me know if this helps. Please don’t share the docs yet as the robot is not officially released yet.

Kind regards,
Tim

eric.gay
#3

Hey Tim, that seems to do the trick.

I simply added a filter robot right before my image resizing, then another filter robot at the end to filter for PDFs and upload original. Deployed to production and working so far.

tim-kos
#4

Awesome.

Closing this for now then. Feel free to reopen if you need anything.