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.
a filename
# File lib/carrierwave/uploader/store.rb, line 24 def filename @filename end
Retrieves the file from the storage.
uniquely identifies the file to retrieve
# File lib/carrierwave/uploader/store.rb, line 70 def retrieve_from_store!(identifier) with_callbacks(:retrieve_from_store, identifier) do @file = storage.retrieve!(identifier) end end
Stores the file by passing it to this Uploader’s storage engine.
If new_file is omitted, a previously cached file will be stored.
any kind of file object
# File lib/carrierwave/uploader/store.rb, line 53 def store!(new_file=nil) cache!(new_file) if new_file if @file and @cache_id with_callbacks(:store, new_file) do @file = storage.store!(@file) @cache_id = nil end end end
Calculates the path where the file should be stored. If
for_file is given, it will be used as the filename, otherwise
+CarrierWave::Uploader#filename+ is assumed.
name of the file <optional>
the store path
# File lib/carrierwave/uploader/store.rb, line 40 def store_path(for_file=filename) File.join([store_dir, full_filename(for_file)].compact) end