cloudinary / cloudinary_gem

Cloudinary GEM for Ruby on Rails integration
https://cloudinary.com
420 stars 285 forks source link

ActiveStorage support for upload_large #510

Closed adriennhem closed 1 year ago

adriennhem commented 1 year ago

I have implemented support for ActiveStorage using the guide available at: https://cloudinary.com/documentation/rails_activestorage

I am getting a 413 error when attempting to upload a large video file > 100MB server-side. This is normal as per your documentation but does your implementation of ActiveStorage does not handle large files on its own?

Using a pretty basic code:

   recording = Recording.create(
      account_id: room.account_id,
      file: ActiveStorage::Blob.create_and_upload!( 
        io: temp_file,
        filename: "#{room.whereby_room_name.gsub('/', '')}.mp4",
        content_type: 'video/mp4'
      ),
      live: true,
      source: 'lsc',
      customer_email: customer_email,
      room_id: room.id
    )

Any workaround?

adriennhem commented 1 year ago

Looks like there is no upload_large option in cloudinary_service.rb

def upload(key, io, filename: nil, checksum: nil, **options)
      instrument :upload, key: key, checksum: checksum do
        begin
          extra_headers = checksum.nil? ? {} : {Headers::CONTENT_MD5 => checksum}
          options = @options.merge(options)
          Cloudinary::Uploader.upload(
            io,
            public_id: public_id_internal(key),
            resource_type: resource_type(io, key),
            context: {active_storage_key: key, checksum: checksum},
            extra_headers: extra_headers,
            **options
          )
        rescue CloudinaryException => e
          raise ActiveStorage::IntegrityError, e.message, e.backtrace
        end
      end
    end
tommyg-cld commented 1 year ago

yes currently upload_large is not supported via Active Storage but this is in our backlog to complete. I don't have an ETA right now but will keep you posted.