Class: Fastlane::Actions::SqCiToolsUploadFileToS3Action
- Inherits:
-
Action
- Object
- Action
- Fastlane::Actions::SqCiToolsUploadFileToS3Action
- Defined in:
- lib/fastlane/plugin/sq_ci_tools/actions/sq_ci_tools_upload_file_to_s3_action.rb
Class Method Summary collapse
- .authors ⇒ Object
- .available_options ⇒ Object
- .description ⇒ Object
- .details ⇒ Object
- .is_supported?(_) ⇒ Boolean
- .return_type ⇒ Object
- .return_value ⇒ Object
- .run(params) ⇒ Object
Class Method Details
.authors ⇒ Object
75 76 77 |
# File 'lib/fastlane/plugin/sq_ci_tools/actions/sq_ci_tools_upload_file_to_s3_action.rb', line 75 def self. ['Semen Kologrivov'] end |
.available_options ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/fastlane/plugin/sq_ci_tools/actions/sq_ci_tools_upload_file_to_s3_action.rb', line 49 def self. [ FastlaneCore::ConfigItem.new( key: :file_path, description: 'Path to file for upload', optional: false, type: String ), FastlaneCore::ConfigItem.new( key: :relative_path, description: 'Relative path to file on s3 storage', optional: true, type: String ) ] + Options::S3. end |
.description ⇒ Object
41 42 43 |
# File 'lib/fastlane/plugin/sq_ci_tools/actions/sq_ci_tools_upload_file_to_s3_action.rb', line 41 def self.description 'Upload file to S3-compatible storage' end |
.details ⇒ Object
45 46 47 |
# File 'lib/fastlane/plugin/sq_ci_tools/actions/sq_ci_tools_upload_file_to_s3_action.rb', line 45 def self.details '' end |
.is_supported?(_) ⇒ Boolean
79 80 81 |
# File 'lib/fastlane/plugin/sq_ci_tools/actions/sq_ci_tools_upload_file_to_s3_action.rb', line 79 def self.is_supported?(_) true end |
.return_type ⇒ Object
67 68 69 |
# File 'lib/fastlane/plugin/sq_ci_tools/actions/sq_ci_tools_upload_file_to_s3_action.rb', line 67 def self.return_type :string end |
.return_value ⇒ Object
71 72 73 |
# File 'lib/fastlane/plugin/sq_ci_tools/actions/sq_ci_tools_upload_file_to_s3_action.rb', line 71 def self.return_value 'Link for uploaded file' end |
.run(params) ⇒ Object
9 10 11 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 39 |
# File 'lib/fastlane/plugin/sq_ci_tools/actions/sq_ci_tools_upload_file_to_s3_action.rb', line 9 def self.run(params) access_key = params[:s3_access_key_id] key_secret = params[:s3_secret_access_key] bucket_name = params[:s3_bucket_name] region_name = params[:s3_region_name] endpoint = params[:s3_endpoint] file_path = params[:file_path] filename = File.basename(file_path) file_key = [params[:relative_path], filename].compact.reject(&:empty?).join("/") credentials = Aws::Credentials.new(access_key, key_secret) s3_client = Aws::S3::Client.new( region: region_name, credentials: credentials, endpoint: endpoint ) # https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/S3/Client.html#put_object-instance_method s3_client.put_object( acl: 'public-read', body: File.open(file_path), bucket: bucket_name, key: file_key ) uploaded_object = Aws::S3::Object.new(bucket_name, file_key, client: s3_client) public_url = uploaded_object.public_url return public_url end |