refacto upload archive

This commit is contained in:
Christophe Robillard 2023-08-02 10:32:49 +02:00 committed by mfo
parent b781e4d466
commit 9445c12b4d

View file

@ -6,19 +6,7 @@ class ArchiveUploader
def upload(archive) def upload(archive)
uploaded_blob = create_and_upload_blob uploaded_blob = create_and_upload_blob
begin archive.file.attach(uploaded_blob)
archive.file.purge if archive.file.attached?
rescue ActiveStorage::FileNotFoundError
archive.file.destroy
archive.file.detach
end
archive.reload
ActiveStorage::Attachment.create(
name: 'file',
record_type: 'Archive',
record_id: archive.id,
blob_id: uploaded_blob.id
)
end end
def blob def blob