Module: Dscf::Core::FileStorage

Defined in:
app/services/dscf/core/file_storage.rb,
app/services/dscf/core/file_storage/client.rb,
app/services/dscf/core/file_storage/uploader.rb

Defined Under Namespace

Classes: Client, Uploader

Class Method Summary collapse

Class Method Details

.delete(file_key) ⇒ Boolean

Delete a file

Parameters:

  • file_key (String)

Returns:

  • (Boolean)


38
39
40
# File 'app/services/dscf/core/file_storage.rb', line 38

def delete(file_key)
  Client.new.delete(file_key)
end

.download(file_key) ⇒ Hash

Quick download method

Parameters:

  • file_key (String)

Returns:

  • (Hash)

    { data:, filename:, content_type: }



24
25
26
# File 'app/services/dscf/core/file_storage.rb', line 24

def download(file_key)
  Client.new.download(file_key)
end

.exists?(file_key) ⇒ Boolean

Check if a file exists

Parameters:

  • file_key (String)

Returns:

  • (Boolean)


31
32
33
# File 'app/services/dscf/core/file_storage.rb', line 31

def exists?(file_key)
  Client.new.exists?(file_key)
end

.upload(file, **options) ⇒ Hash?

Quick upload method for simple use cases

Parameters:

  • file (ActionDispatch::Http::UploadedFile, File, Hash)
  • options (Hash)

    uploader options

Returns:

  • (Hash, nil)

    { file_key:, filename:, content_type:, size:, metadata: }



17
18
19
# File 'app/services/dscf/core/file_storage.rb', line 17

def upload(file, **options)
  Uploader.new(options).upload(file)
end