Class: AppStage::UploadFile
- Inherits:
-
Object
- Object
- AppStage::UploadFile
- Defined in:
- lib/upload_file.rb
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(options) ⇒ UploadFile
constructor
A new instance of UploadFile.
Constructor Details
#initialize(options) ⇒ UploadFile
Returns a new instance of UploadFile.
8 9 10 |
# File 'lib/upload_file.rb', line 8 def initialize() @options = end |
Instance Method Details
#execute ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/upload_file.rb', line 12 def execute begin host = @options[:host] || "https://www.appstage.io" raise('No file specified') unless @options[:upload] file_path = File.(@options[:upload]) filename = File.basename(@options[:upload]) raise('Invalid project token') unless @options[:jwt] token = @options[:jwt] file_size = File.size(file_path) puts "Uploading #{filename} #{file_size} bytes..." checksum = calculate_checksum(file_path) direct_upload_response = request_direct_upload(host, token, filename, file_size, checksum) upload_to_cdn(file_path, direct_upload_response) create_release_file(host, token, direct_upload_response['signed_id']) puts "Upload complete" 0 rescue Exception => e puts "Upload failed - #{e}" -1 end end |