Dynamic headers problem

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

Hey guys,

I’ve got a template that looks like this:

{ "steps": {
    "mp3": {
      "use": ":original",
      "robot": "/audio/encode",
      "preset": "mp3"
    },
    "theora.ogv": {
      "use": ":original",
      "robot": "/audio/encode",
      "ffmpeg": {
        "acodec": "libvorbis",
        "f": "ogg"
      }
    },
    "store-mp3": {
      "use": ["mp3"],
      "robot": "/s3/store",
      "path": "${unique_prefix}.${previous_step.name}",
      "bucket": "kera-production",
      "key": "",
      "secret": ""
    },
    
    "store-ogg": {
      "use": ["theora.ogv"],
      "robot": "/s3/store",
      "path": "${unique_prefix}.${previous_step.name}",
      "headers": { "Content-Type": "audio/ogg" },
      "bucket": "kera-production",
      "key": "",
      "secret": ""
    }
} }

I NEED the ogg format to be stored with the header ‘audio/ogg’ for use with Firefox/HTML5. Is there a more efficient way of doing this? By default the content type for ogg is set to x-audio/ogg. Ideally I’d specify a variable in the /audio/encode step which can be used in the ‘store’ step but I’m not sure if this is possible?

Thanks.

-Cameron

Hey Cameron,

thanks for submitting the ticket.

I am not quite sure, though, what the questions is, because your syntax with the Content-type header looks just fine and is also the most efficient way.

Could you please explain more how you intend the variable to work? Maybe you mean something like this: https://transloadit.com/docs/passing-fields-and-variables-into-templates ?

Kind regards,
Tim

Hey Tim,

The Content-Type header IS fine. My concern is that I’ve had to add two different /s3/store robots in order to accomplish the task. This means a lot of the configuration for those robots are duplicated causing a maintenance headache. It would be nicer if I could set the content-type dynamically based on the previous steps. Please take a closer look and I think it should be obvious.

-Cameron

Sorry for the confusion. I see what you mean. Unfortunately our API currently does not allow for a more efficient way to deal with this. That being said, it seems like we could also solve your problem by making sure we make audio/ogg the default header for ogg? What do you think?

That would be fantastic if you could do that. I was trying to see if there was an argument that I could pass to ffmpeg or something to no avail.

Is that a possibility?

Yes, that’s possible.

Tim: Can you hack this in?

Hacked this in a few weeks ago. Enjoy!

Closing this ticket for now.

Ok so what does that mean? That I don’t need to specify the header anymore?
What should I change my template to look like after your “hack”?

The “hack” automatically sets the proper Content-type header if the file that needs storing is identified to have the audio/ogg mime type.

kind regards,
Tim

Co-Founder Transloadit
@tim_kos

Ok Tim thanks.

Alright, closing this ticket.