migrating legacy images into cloudinary using Rails console

Comments

6 comments

  • Avatar
    Daniel Mendoza

    @Steve

    A few clarification questions, when you refer to console, you mean the rails console, and not the Cloudinary console?
    Second, I assume this may have been done but I would rather check. When you added Active Storage, did you also reference Cloudinary as the storage service (https://cloudinary.com/documentation/rails_activestorage#active_storage_configuration) ?

    If you wish to share personal details about your project, please feel free to open a support ticket here:
    https://support.cloudinary.com/hc/en-us/requests/new


    I am looking forward to your update.

    0
    Comment actions Permalink
  • Avatar
    Steve Quezadas

    > when you refer to console, you mean the rails console, and not the Cloudinary console?
    I meant to say "rails console".

    > did you also reference Cloudinary as the storage service
    Yes, I referenced cloudinary as the storage service in the config file. I am able to store cloudinary files from the rails console file. For instance, "Cloudinary::Uploader.upload('https://website.com/image.jpg')" works fine.

    0
    Comment actions Permalink
  • Avatar
    Steve Quezadas

    I was able to save to cloudinary using active storage on ruby on rails from a weblink by using the following code. I am putting something here so others can benefit:

    require 'open-uri'
    theImage = open("https://website.com/image.png")
    profile = Profile.new
    profile.avatar.attach(io: theImage, filename: 'image.png')
    profile.save

    Does anyone know how to set the public key from commandline though?

    0
    Comment actions Permalink
  • Avatar
    Daniel Mendoza

    @Steve
    Glad you were able to upload the asset. I would like to add that you cannot set the public id of the asset, this is a feature that's not available in Active Storage. It will be a randomly generated key after upload.

    0
    Comment actions Permalink
  • Avatar
    Steve Quezadas

    Can you set a folder for active storage?

    0
    Comment actions Permalink
  • Avatar
    Wissam Khalili

    Hi Steve,

    You cannot specify an upload preset or other upload parameters on a per-upload basis while using Active Storage. There are however two ways to globally specify upload parameters for all uploads:

    • As an upload preset (or upload parameters) in the Rails service configuration (as top-level parameters)
    • As a default upload preset specified via the console which will be applied to all uploads without any extra code on the Rails side

    Please note It is possible to pass Upload API parameters in your ActiveStorage calls by configuring those parameters in your config/storage.yml file - https://cloudinary.com/documentation/rails_activestorage#active_storage_configuration - such as passing "folder: testing" on a new line below "service: Cloudinary" - will apply that for all uploads and store the assets in that folder. You can also pass an upload preset that contains different settings to apply for each upload.

    Thanks, Wissam

    0
    Comment actions Permalink

Please sign in to leave a comment.