In my uploader, if I am overriding the filename method present in Store.rb library of carrierwave, then upload functionality is not working. It is showing code executed properly but file was not uploaded on GCS bucket.
Below is the Carrierwave lib:
##
# Override this in your Uploader to change the filename.
#
# Be careful using record ids as filenames. If the filename is stored in the database
# the record id will be nil when the filename is set. Don't use record ids unless you
# understand this limitation.
#
# Do not use the version_name in the filename, as it will prevent versions from being
# loaded correctly.
#
# === Returns
#
# [String] a filename
#
def filename
@filename
end
This is what I implemented after overriding:
def filename
case model.type
when :video
"video_file"
when :mp3
"mp3_file"
end
end
Any help would be appreciated here. I wanted to change the filename if file is video or audio while uploading.
Aucun commentaire:
Enregistrer un commentaire