Class: Shrine::Storage::Tus

Inherits:
Url
  • Object
show all
Defined in:
lib/shrine/storage/tus.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tus_storage: nil, **options) ⇒ Tus

Returns a new instance of Tus.



10
11
12
13
14
# File 'lib/shrine/storage/tus.rb', line 10

def initialize(tus_storage: nil, **options)
  @tus_storage = tus_storage

  super(delete: true, **options)
end

Instance Attribute Details

#tus_storageObject (readonly)

Returns the value of attribute tus_storage.



8
9
10
# File 'lib/shrine/storage/tus.rb', line 8

def tus_storage
  @tus_storage
end

Instance Method Details

#open(id, **options) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/shrine/storage/tus.rb', line 16

def open(id, **options)
  return super unless tus_storage

  open_from_tus_storage(tus_uid(id), **options)
rescue => error
  raise error unless tus_not_found?(error)
  raise Shrine::FileNotFound, "file #{id.inspect} not found on storage"
end