Class: Ribose::FileUploader

Inherits:
Object
  • Object
show all
Defined in:
lib/ribose/file_uploader.rb

Direct Known Subclasses

VersionUploader

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(space_id, file:, **attributes) ⇒ FileUploader

Initialize the file uploader

Parameters:

  • space_id (String)

    The Space UUID

  • file (File)

    The complete path for file

  • attributes (Hash)

    Attributes as a Hash



12
13
14
15
16
# File 'lib/ribose/file_uploader.rb', line 12

def initialize(space_id, file:, **attributes)
  @space_id = space_id
  @file = File.new(file)
  @attributes = attributes
end

Class Method Details

.upload(space_id, file:, **attributes) ⇒ Sawyer::Resource

Create a new upload

Parameters:

  • space_id (String)

    The Space UUID

  • file (File)

    The complete path for file

  • attributes (Hash)

    Attributes as a Hash

Returns:

  • (Sawyer::Resource)

    File upload response.



33
34
35
# File 'lib/ribose/file_uploader.rb', line 33

def self.upload(space_id, file:, **attributes)
  new(space_id, attributes.merge(file: file)).create
end

Instance Method Details

#createSawyer::Resource

Create a file upload

Returns:

  • (Sawyer::Resource)

    File upload response.



21
22
23
24
25
# File 'lib/ribose/file_uploader.rb', line 21

def create
  upload_meta = prepare_to_upload
  response = upload_to_aws_s3(upload_meta)
  notify_ribose_file_upload_endpoint(response, upload_meta.fields.key)
end