Class: Bcli::Commands::Drive::Upload
- Inherits:
-
Bcli::Command
- Object
- Bcli::Command
- Bcli::Commands::Drive::Upload
- Defined in:
- lib/bcli/commands/drive/upload.rb
Instance Method Summary collapse
- #execute(input: $stdin, output: $stdout) ⇒ Object
- #file_client ⇒ Object
-
#initialize(options) ⇒ Upload
constructor
A new instance of Upload.
Methods inherited from Bcli::Command
#ask, #client, #config, #credentials, #download, #link_to, #logger, #open_in_browser, #parse_json, #pastel, #prompt
Constructor Details
#initialize(options) ⇒ Upload
Returns a new instance of Upload.
9 10 11 |
# File 'lib/bcli/commands/drive/upload.rb', line 9 def initialize() @options = end |
Instance Method Details
#execute(input: $stdin, output: $stdout) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/bcli/commands/drive/upload.rb', line 13 def execute(input: $stdin, output: $stdout) res = file_client.upload if res.code == 201 response = parse_json(res) puts pastel.green "Upload successful!\n" puts pastel.green response.url else puts pastel.red "Upload failed!" puts pastel.red res.body end end |
#file_client ⇒ Object
26 27 28 29 30 |
# File 'lib/bcli/commands/drive/upload.rb', line 26 def file_client local_file_path = ask("Enter the path to the file you want to upload: ") remote_folder_path = ask("Enter the path to the folder you want to upload to: (optional)") @file_client ||= Bcli::FileClient.new(local_file_path, folder_path: remote_folder_path) end |