Closed desertwinds closed 8 years ago
Hi, I can't seem to get this gem working and I narrowed it down to the fact that for some reason I can't get the right key. This is my setup
Please use proper markdown syntax to post ruby fragments.
class UploadsController < ApplicationController def new @uploader = FileUpload.new.upload @uploader.success_action_redirect = new_file_upload_url
Here you are redirecting users to /file_uploads/new
but your logic to store the upload is in create action so there is something wrong in your implementation.
Also please post your upload form.
However, the thing is that using binding.pry on my create function it seems that I'm not getting the right key. I can see on the URL something like this "http://localhost:3000/file_uploads/new?bucket=bucketname&key=uploads%2F3cf6d33a-4ac8-4678-a02a-feae44a13f81%2Image.jpg&etag=%228b14e676f2d53f71648d27f62fc6cbe0%22"
Your create action will never be invoked because of new_file_upload_url
above I don't know these params came from.
Is there something I'm doing wrong?
The flow when using this gem is:
success_action_redirect
with a key paramIt seems that you're missing point 2 and 3.
Closing this because it's not an issue but an usage question.
Hi, I can't seem to get this gem working and I narrowed it down to the fact that for some reason I can't get the right key. This is my setup
class FileUpload < ActiveRecord::Base mount_uploader :upload, UploadUploader
end
class UploadUploader < CarrierWave::Uploader::Base include CarrierWaveDirect::Uploader end
class UploadsController < ApplicationController def new @uploader = FileUpload.new.upload @uploader.success_action_redirect = new_file_upload_url end end
On my FileUploadsController
def create @file_upload = @file_uploads.build(file_upload_params) if @file_upload.save FileUploadJob.perform_later(@file_upload.id, @file_upload.key) flash.now[:notice] = "File has been uploaded and it's being processed. Refresh at will." else render :new end end
And finally my background job
class FileUploadJob < ActiveJob::Base queue_as :file_upload_processor_queue
def perform(file_upload_id, upload_key) file_upload = FileUpload.find(file_upload_id) file_upload.key = upload_key file_upload.remote_upload_url = file_upload.upload.direct_fog_url(:with_path => true) file_upload.save! end end
However, the thing is that using binding.pry on my create function it seems that I'm not getting the right key. I can see on the URL something like this "http://localhost:3000/file_uploads/new?bucket=bucketname&key=uploads%2F3cf6d33a-4ac8-4678-a02a-feae44a13f81%2Image.jpg&etag=%228b14e676f2d53f71648d27f62fc6cbe0%22" But when I try to get the key on my controller I get is something like this "uploads/11b72014-4b19-4f21-a9ec-b2baf307ce90/${filename}"
Is there something I'm doing wrong? I read that you can't call the column "file", is "upload" a problem as well?