Template question

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

Hi there -

we’re a happy customer with a question:

we’d like to use one template to upload attachments, which could be of these types:

a) image - we’d like to resize and save to s3

b) video - we’d like to encode mp4 and webm and save to s3

c) pdf - we’d like to save original to s3

our current template does this, but resdudantly saves all the originals on top. how can we prevent that from happening / make it even smarter?

  templates:
    message_attachment:
      template_id: REDACTED #the basic template with step order and s3 credentials is on transloadit
      steps:
        resize:
          use: ":original"
          robot: "/image/resize"
          width: 1920
          height: 1920
          resize_strategy: "fit"
          strip: true #remove meta data
          zoom: false #don't enlarge smaller images
          format: "jpg" #always store jpg
          quality: 70 #compression
          result: false
        encode_webm:
          use: ":original"
          robot: "/video/encode"
          preset: "webm"
          width: 480
          height: 320
          result: false
        encode_mp4:
          use: ":original"
          robot: "/video/encode"
          preset: "iphone"
          width: 480
          height: 320
          result: false
        extract_thumb:
          use: encode_mp4
          robot: '/video/thumbs'
          offsets: ['2%']
          format: 'jpeg'
          width: 480
          height: 320
          resize_strategy: 'fit'
          result: false
        store:
          use: [":original", "resize", "encode_webm", "encode_mp4", 'extract_thumb']
          bucket: "professors"
          path: "task-attachments/${unique_original_prefix}-${file.name}" #we use a uniqe prefix to avoid file name colissions

thank you so much!

Philipp / Ludinc GmbH

i’ve uploaded the actual file as my paste above got mangled.

Hi Philipp,

Since you are using :original in your store step, all original files get stored.
You could make more intelligent flows using our file/filter bot.

You could name the step that filters pdf filters: filtered_pdf, and then change your store’s use to e.g.

          use: ["filtered_pdf", "resize", "encode_webm", "encode_mp4", 'extract_thumb']

More on the file/filter bot and it’s usage can be found here https://transloadit.com/docs/conversion-robots#file-filter

Hope this helps,
Kevin