Class: Poto::FileRepository::AWS::S3

Inherits:
Object
  • Object
show all
Defined in:
lib/poto/file_repository/aws/s3.rb,
lib/poto/file_repository/aws/s3/client.rb,
lib/poto/file_repository/aws/s3/file_mapper.rb,
lib/poto/file_repository/aws/s3/file_collection_mapper.rb

Defined Under Namespace

Classes: Client, FileCollectionMapper, FileMapper

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(bucket:, client: Client.new(bucket)) ⇒ S3

Returns a new instance of S3.



11
12
13
14
# File 'lib/poto/file_repository/aws/s3.rb', line 11

def initialize(bucket:, client: Client.new(bucket))
  @bucket = bucket
  @client = client
end

Instance Attribute Details

#bucketObject (readonly)

Returns the value of attribute bucket.



9
10
11
# File 'lib/poto/file_repository/aws/s3.rb', line 9

def bucket
  @bucket
end

#clientObject (readonly)

Returns the value of attribute client.



9
10
11
# File 'lib/poto/file_repository/aws/s3.rb', line 9

def client
  @client
end

Instance Method Details

#all(prefix:, page:, per_page:) ⇒ Object



20
21
22
23
24
25
26
27
28
# File 'lib/poto/file_repository/aws/s3.rb', line 20

def all(prefix:, page:, per_page:)
  objects = client.objects(
    page:     page,
    per_page: per_page,
    prefix:   prefix
  )

  FileCollectionMapper.new(objects).call
end

#url(id) ⇒ Object



16
17
18
# File 'lib/poto/file_repository/aws/s3.rb', line 16

def url(id)
  client.url(id)
end