attachinary rails form_for attachinary_file_field set public_id option
Is there a way to set public_id in a Rails html form_for? My code is:
<%= f.attachinary_file_field :media0, :public_id => "Image1" %>
This runs fine but cloudinary saves a random id.
I cant seem an answer to this anywhere and I have tried numerous variations of the above code.
Thanks, Bryant
-
Hi Bryant,
The maintainers of the attachinary gem have their own documentation and issue tracker available here in GitHub which may be helpful: https://github.com/assembler/attachinary
I think based on the way that project works, that it's not possible to override the default upload options in the requests it makes, but if instead of a random value, you want the files named based on the uplaoded file's name, you can change the default method used to for selecting the public_id by changing the default Upload Preset in your account settings: https://cloudinary.com/documentation/upload_presets
In the upload preset, you can specify "use_filename: true" and we'll use the filename of the uploaded file as a base, then add some random characters at the end to avoid collisions. You can use the filename without random characters by also specifying "unique_filename: false" in the preset
Regards,
Stephen
Please sign in to leave a comment.
Comments
1 comment