attachinary icon indicating copy to clipboard operation
attachinary copied to clipboard

Support for private file uploads

Open maletor opened this issue 12 years ago • 9 comments

CarrierWave supports adding make_private to the attachment. Is that also possible through attachinary?

Relevant url: http://cloudinary.com/blog/how_to_quickly_build_a_stock_photo_site_using_cloudinary

maletor avatar Jun 11 '13 21:06 maletor

Thanks for the suggestion. I've checked those docs and see that it is possible, but just not currently supported by attachinary. I'll add it to my list. In the mean time, you can fork the project and change the Cloudinary::Uploader.upload call to include type: 'private' option.

assembler avatar Jun 12 '13 07:06 assembler

I'll be taking this on in a short while.

maletor avatar Jun 13 '13 16:06 maletor

Any update on this one? I have a need of storing private documents and i am thinking of using carrierwave but attachinary is so much easier to use. With carrierwave i have to create an extra AR model as it will be a has_many documents situation. As a side note, these documents can be anything.. word, pdf, images.. etc.

kbaum avatar Aug 01 '13 13:08 kbaum

Yes, attachinary already supports this. You must modify data-form to have the private flag. Also, the attachinary response will tell you if the file uploaded is an image or "raw".

http://cloudinary.com/documentation/upload_images

On Thu, Aug 1, 2013 at 6:57 AM, Karl Baum [email protected] wrote:

Any update on this one? I have a need of storing private documents and i am thinking of using carrierwave but attachinary is so much easier to use. With carrierwave i have to create an extra AR model as it will be a has_many documents situation. As a side note, these documents can be anything.. word, pdf, images.. etc.

— Reply to this email directly or view it on GitHubhttps://github.com/assembler/attachinary/issues/57#issuecomment-21937836 .

maletor avatar Aug 01 '13 14:08 maletor

Awesome! Once i upload a private file to cloudinary, how can we access it? For example, s3 has an expiring url that i can temporarily give to a user once they have been authorized.

thx!

kbaum avatar Aug 01 '13 15:08 kbaum

Try Cloudinary::Utils.cloudinary_url.

https://github.com/cloudinary/cloudinary_gem/blob/master/lib/cloudinary/utils.rb#L211-L218.

maletor avatar Aug 06 '13 07:08 maletor

@maletor - I see attachinary already takes care of the data-form-data attribute for me. What's the cleanest way to add a configuration parameter to this?

thx!

kbaum avatar Aug 14 '13 22:08 kbaum

@maletor - i figured out how to pass the data-form-data attributes. My code looks like:

= f.attachinary_file_field :documents, cloudinary: { type: :private, resource_type: :raw, transformation: :attachment, use_filename: true, image_metadata: true, discard_original_filename: false }

But i get an error back from cloudinary:

{"error":{"message":"Invalid value private for parameter raw_kind"}}

If i remove type:private, it works.

thx!

-karl

kbaum avatar Aug 16 '13 03:08 kbaum

Ok, was able to get private uploads working, but not with a raw file type. The following code works when attaching an image:

= f.attachinary_file_field :documents, cloudinary: { type: :private }

But it does not work if i attach a raw file type like an xls document. Along the same lines, the following code, never works as I am explicitly passing in raw:

= f.attachinary_file_field :documents, cloudinary: { type: :private, resource_type: :raw }

I get back the following error from cloudinary:

{"error":{"message":"Invalid value private for parameter raw_kind"}}

thx!

kbaum avatar Aug 16 '13 03:08 kbaum