Class: SonyCiAdmin::Uploader
- Inherits:
-
SonyCiClient
- Object
- SonyCiClient
- SonyCiAdmin::Uploader
- Defined in:
- lib/sony_ci_api/sony_ci_admin.rb
Overview
:nodoc:
Constant Summary collapse
- CHUNK_SIZE =
Chunk size 10 for multipart upload.
10 * 1024 * 1024
Instance Method Summary collapse
-
#initialize(ci, path, log_path) ⇒ Uploader
constructor
A new instance of Uploader.
- #upload ⇒ Object
Methods inherited from SonyCiClient
Constructor Details
#initialize(ci, path, log_path) ⇒ Uploader
Returns a new instance of Uploader.
116 117 118 119 120 |
# File 'lib/sony_ci_api/sony_ci_admin.rb', line 116 def initialize(ci, path, log_path) @ci = ci @path = path @log_file = File.open(log_path, 'a') end |
Instance Method Details
#upload ⇒ Object
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/sony_ci_api/sony_ci_admin.rb', line 122 def upload file = File.new(@path) if file.size >= CHUNK_SIZE initiate_multipart_upload(file) part = 0 part = do_multipart_upload_part(file, part) while part complete_multipart_upload else singlepart_upload(file) end row = [Time.now, File.basename(@path), @asset_id, @ci.detail(@asset_id).to_s.gsub("\n", ' ')] @log_file.write(row.join("\t") + "\n") @log_file.flush @asset_id end |