Merge pull request #5400 from betagouv/add-test-for-zip-download

Ajout d'un test pour le telechargement de zips de dossier
This commit is contained in:
Keirua 2020-07-21 17:39:39 +02:00 committed by GitHub
commit f583b16f92
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 101 additions and 4 deletions

View file

@ -24,11 +24,14 @@ class ActiveStorage::DownloadableFile
private
def self.timestamped_filename(piece_justificative)
# we pad the original file name with a timestamp
# and a short id in order to help identify multiple versions and avoid name collisions
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")
timestamp = piece_justificative.created_at.strftime("%d-%m-%Y-%H-%M")
id = piece_justificative.id % 10000
"#{basename}-#{timestamp}#{extension}"
"#{basename}-#{timestamp}-#{id}#{extension}"
end
def using_local_backend?