Class: Scholarsphere::S3::Uploader
- Inherits:
-
Object
- Object
- Scholarsphere::S3::Uploader
- Defined in:
- lib/scholarsphere/s3/uploader.rb
Overview
Uploads a file to Scholarsphere's AWS S3 instance. When upload is invoked, a pre-signed URL is requested from Scholarsphere, and if successful, the file is then uploaded to Scholarsphere using the url.
An md5 hash is calculated for the file at initialization to ensure the file is transferred successfully.
Example
uploaded_file = Scholarsphere::S3::UploadedFile.new('path/to/file')
uploader = Scholarsphere::S3::Uploader(file: uploaded_file)
response = uploader.upload
Instance Method Summary collapse
-
#initialize(file:) ⇒ Uploader
constructor
A new instance of Uploader.
-
#upload ⇒ Faraday::Response
The response from Scholarsphere to the upload request.
Constructor Details
#initialize(file:) ⇒ Uploader
Returns a new instance of Uploader.
20 21 22 23 |
# File 'lib/scholarsphere/s3/uploader.rb', line 20 def initialize(file:) @file = file @content_md5 = file.content_md5 end |