Rails - Dragonfly image upload to OCI using angular frontend

40 Views Asked by At

I am uploading a file in angular and returning rails params in imageData and imageContent variable. Then in rails controller, I try to create a temp file using those parameters and assign it to the dragonfly accessor attribute but it doesn't get uploaded on save. Though I've verified the file upload to OCI Object storage in rails console, its working fine.

  dragonfly_accessor :logo do
    storage_options do |attachment|
      {
        path: "brand_logos/"
      }
    end
  end
    decoded_data = Base64.decode64(params[:brand][:logo][:imageData]) # json parameter set in directive scope
    file_name = params[:brand][:logo][:imagePath]
    File.open(file_path, 'wb+') { |file| file.write(decoded_data) }
    params[:brand][:logo][:tempfile] = file_path # json parameter set in directive scope
0

There are 0 best solutions below