refacto upload archive
This commit is contained in:
parent
b781e4d466
commit
9445c12b4d
1 changed files with 1 additions and 13 deletions
|
@ -6,19 +6,7 @@ class ArchiveUploader
|
|||
|
||||
def upload(archive)
|
||||
uploaded_blob = create_and_upload_blob
|
||||
begin
|
||||
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
|
||||
)
|
||||
archive.file.attach(uploaded_blob)
|
||||
end
|
||||
|
||||
def blob
|
||||
|
|
Loading…
Reference in a new issue