Class: Scholarsphere::Client::Upload

Inherits:
Object
  • Object
show all
Defined in:
lib/scholarsphere/client/upload.rb

Overview

Requests a pre-signed url, id, and prefix from Scholarsphere for uploading a given file. In order to generate a correct path, the file's extension name is required for the request. The url is used to upload the file's binary content into Scholarsphere, while the id and key are used when adding the file to a work.

Instance Method Summary collapse

Constructor Details

#initialize(extname:, content_md5:) ⇒ Upload

Returns a new instance of Upload.

Parameters:

  • extname (String)

    Extension of the file to be uploaded, without the period, such as 'pdf'

  • content_md5 (String)

    This should be the same as UploadedFile.content_md5



14
15
16
17
# File 'lib/scholarsphere/client/upload.rb', line 14

def initialize(extname:, content_md5:)
  @extname = extname
  @content_md5 = content_md5
end

Instance Method Details

#idString

Returns A unique identifier for the file which will serve as its name in S3.

Returns:

  • (String)

    A unique identifier for the file which will serve as its name in S3.



30
31
32
# File 'lib/scholarsphere/client/upload.rb', line 30

def id
  data['id']
end

#prefixString

Returns Prefix where the file is stored in the S3 bucket.

Returns:

  • (String)

    Prefix where the file is stored in the S3 bucket.



20
21
22
# File 'lib/scholarsphere/client/upload.rb', line 20

def prefix
  data['prefix']
end

#urlString

Returns URL for uploading the file into AWS.

Returns:

  • (String)

    URL for uploading the file into AWS.



25
26
27
# File 'lib/scholarsphere/client/upload.rb', line 25

def url
  data['url']
end