I am using dropzone
to send an .xlsx
file to my controller, that sends me the file by parameters and I get an <ActionDispatch::Http::UploadedFile:0x007fe9f87bb030
In my controller I am trying to receive and read it but it does not work
def update_activities_with_excel
file = params[:file].tempfile
File.open(file, 'r') do |file|
end
end
file
prints:
#<File:/tmp/RackMultipart20190731-16696-1khug2d.xlsx>
My parameters:
Parameters: {
"file"=>#<ActionDispatch::Http::UploadedFile:0x007fe9f87bb030
@tempfile=#<Tempfile:/tmp/RackMultipart20190731-16696-1khug2d.xlsx>,
@original_filename="Actividades.xlsx",
@content_type="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
@headers="Content-Disposition: form-data; name=\"file\";
filename=\"Actividades.xlsx\"\r\n
Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\r\n">}
I need to get its content to process it, I am using the axlsx gem
I found the solution using the creek gem
file = params[:file]
creek = Creek::Book.new file.tempfile