Tomas Romero
Tomas Romero

Reputation: 8698

Generate download/attachment url for Cloudinary private image through gem

I'm using gem 'cloudinary', '1.0.63'.

To generate a download url I use attachment flag:

Cloudinary::Utils.unsigned_download_url self.cloudinary_id, format: self.format, flags: :attachment

This works with public images. Although, when trying to achieve the same with private images, it doesn't:

Cloudinary::Utils.private_download_url self.cloudinary_id, self.format, flags: :attachment

This last returns the same url as if flags: :attachment wasn't there.

I tried appending /fl_attachment to the generated url without success.

Is it posible to generate the attachment url with private images?

Upvotes: 1

Views: 1568

Answers (2)

hoodslide
hoodslide

Reputation: 631

None of the above "attachment: true" opts work for me (Cloudinary gem 1.0.65), but this does:

options[:transformation][:flags] = "attachment"

If you want multiple flags, join them with a period:

options[:transformation][:flags] = "attachment.keep_iptc"

Setting the attachment flag this way works for the above-mentioned unsigned_download_url() and private_download_url() methods, and even just the #cloudinary_url method.

Cloudinary transformation flags: http://cloudinary.com/documentation/image_transformations#reference

Upvotes: 0

Tal Lev-Ami
Tal Lev-Ami

Reputation: 1457

You can use the following syntax:

Cloudinary::Utils.private_download_url self.cloudinary_id, self.format, attachment: true

Upvotes: 3

Related Questions