Merge pull request #5393 from betagouv/zip-with-identical-files
Zip with identical files
This commit is contained in:
commit
fd8507b531
1 changed files with 10 additions and 2 deletions
|
@ -15,14 +15,22 @@ class ActiveStorage::DownloadableFile
|
|||
pjs = PiecesJustificativesService.liste_pieces_justificatives(dossier)
|
||||
pjs.map do |piece_justificative|
|
||||
[
|
||||
ActiveStorage::DownloadableFile.new(piece_justificative),
|
||||
piece_justificative.filename.to_s
|
||||
piece_justificative,
|
||||
self.timestamped_filename(piece_justificative)
|
||||
]
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def self.timestamped_filename(piece_justificative)
|
||||
extension = File.extname(piece_justificative.filename.to_s)
|
||||
basename = File.basename(piece_justificative.filename.to_s, extension)
|
||||
timestamp = piece_justificative.created_at.strftime("%d-%m-%Y-%H-%S")
|
||||
|
||||
"#{basename}-#{timestamp}#{extension}"
|
||||
end
|
||||
|
||||
def using_local_backend?
|
||||
[:local, :local_test, :test].include?(Rails.application.config.active_storage.service)
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue