Module: ObjectStorage

Defined in:
app/uploaders/object_storage.rb,
lib/object_storage/config.rb,
lib/object_storage/fog_helpers.rb,
app/uploaders/object_storage/s3.rb,
app/uploaders/object_storage/cdn.rb,
lib/object_storage/direct_upload.rb,
lib/object_storage/pending_direct_upload.rb,
app/uploaders/object_storage/cdn/file_url.rb,
app/uploaders/object_storage/cdn/google_cdn.rb,
app/uploaders/object_storage/cdn/google_ip_cache.rb,
app/workers/object_storage/migrate_uploads_worker.rb,
app/workers/object_storage/delete_stale_direct_uploads_worker.rb,
app/services/object_storage/delete_stale_direct_uploads_service.rb

Overview

rubocop:disable Scalability/IdempotentWorker

Defined Under Namespace

Modules: CDN, Concern, Extension, FogHelpers, S3, Store Classes: Config, DeleteStaleDirectUploadsService, DeleteStaleDirectUploadsWorker, DirectUpload, DirectUploadStorage, ExclusiveLeaseTaken, MigrateUploadsWorker, PendingDirectUpload

Constant Summary collapse

RemoteStoreError =
Class.new(StandardError)
UnknownStoreError =
Class.new(StandardError)
ObjectStorageUnavailable =
Class.new(StandardError)
MissingFinalStorePathRootId =
Class.new(StandardError)
TMP_UPLOAD_PATH =
'tmp/uploads'
SUPPORTED_STORES =
[Store::LOCAL, Store::REMOTE].freeze

Instance Method Summary collapse

Instance Method Details

#direct_upload_final_pathObject



619
620
621
# File 'app/uploaders/object_storage.rb', line 619

def direct_upload_final_path
  model.try(direct_upload_final_path_attribute_name)
end

#direct_upload_final_path_attribute_nameObject



615
616
617
# File 'app/uploaders/object_storage.rb', line 615

def direct_upload_final_path_attribute_name
  "#{mounted_as}_final_path"
end

#unsafe_use_fileObject



601
602
603
604
605
606
607
608
609
610
611
612
613
# File 'app/uploaders/object_storage.rb', line 601

def unsafe_use_file
  if file_storage?
    return yield path
  end

  begin
    cache_stored_file!
    yield cache_path
  ensure
    FileUtils.rm_f(cache_path)
    cache_storage.delete_dir!(cache_path(nil))
  end
end