Class: Fastlane::Helper::PerfectoHelper
- Inherits:
-
Object
- Object
- Fastlane::Helper::PerfectoHelper
- Defined in:
- lib/fastlane/plugin/perfecto/helper/perfecto_helper.rb
Class Method Summary collapse
- .parameters(request_part, key, value) ⇒ Object
-
.upload_file(perfecto_cloudurl, perfecto_token, file_path, perfecto_media_fullpath) ⇒ Object
- Uploads file to Perfecto Params :
perfecto_cloudurl
-
Perfecto’s cloud name.
- Uploads file to Perfecto Params :
-
.upload_v1(perfecto_cloudurl, perfecto_token, file_path, perfecto_media_fullpath, artifact_type, artifact_name) ⇒ Object
- Uploads file to Perfecto using new V1 upload API Params :
perfecto_cloudurl
-
Perfecto’s cloud name.
- Uploads file to Perfecto using new V1 upload API Params :
Class Method Details
.parameters(request_part, key, value) ⇒ Object
46 47 48 49 50 |
# File 'lib/fastlane/plugin/perfecto/helper/perfecto_helper.rb', line 46 def self.parameters(request_part, key, value) unless value.to_s.strip.empty? return request_part.merge!(key => value) end end |
.upload_file(perfecto_cloudurl, perfecto_token, file_path, perfecto_media_fullpath) ⇒ Object
Uploads file to Perfecto Params :
perfecto_cloudurl
-
Perfecto’s cloud name.
perfecto_token
-
Perfecto’s security token.
file_path
-
Path to the file to be uploaded.
perfecto_media_fullpath
-
Path to the perfecto media location
DEPRECATED
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/fastlane/plugin/perfecto/helper/perfecto_helper.rb', line 19 def self.upload_file(perfecto_cloudurl, perfecto_token, file_path, perfecto_media_fullpath) unless ENV["http_proxy"] RestClient.proxy = ENV["http_proxy"] end response = RestClient::Request.execute( url: "https://" + perfecto_cloudurl + "/services/repositories/media/" + perfecto_media_fullpath + "?operation=upload&overwrite=true&securityToken=" + URI.encode(perfecto_token, "UTF-8"), method: :post, headers: { "Accept" => "application/json", "Content-Type" => "application/octet-stream", "Expect" => "100-continue" }, payload: File.open(file_path, "rb") ) UI.(response.inspect) rescue RestClient::ExceptionWithResponse => err begin error_response = err.response.to_s rescue error_response = "Internal server error" end # Give error if upload failed. UI.user_error!("App upload failed!!! Reason : #{error_response}") rescue StandardError => error UI.user_error!("App upload failed!!! Reason : #{error.}") end |
.upload_v1(perfecto_cloudurl, perfecto_token, file_path, perfecto_media_fullpath, artifact_type, artifact_name) ⇒ Object
Uploads file to Perfecto using new V1 upload API Params :
perfecto_cloudurl
-
Perfecto’s cloud name.
perfecto_token
-
Perfecto’s security token.
file_path
-
Path to the file to be uploaded.
perfecto_media_fullpath
-
Path to the perfecto media location
artifact_type
-
Artifact Type
artifact_name
-
Artifact Name
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/fastlane/plugin/perfecto/helper/perfecto_helper.rb', line 60 def self.upload_v1(perfecto_cloudurl, perfecto_token, file_path, perfecto_media_fullpath, artifact_type, artifact_name) # prepare cloud url if perfecto_cloudurl.include?(".perfectomobile.com") perfecto_cloudurl = perfecto_cloudurl.split(".perfectomobile.com")[0] if perfecto_cloudurl.include?(".app") perfecto_cloudurl = perfecto_cloudurl.split(".app")[0] end end url = URI("https://" + perfecto_cloudurl + ".app.perfectomobile.com/repository/api/v1/artifacts") https = Net::HTTP.new(url.host, url.port) https.use_ssl = true request = Net::HTTP::Post.new(url) request["Perfecto-Authorization"] = perfecto_token request_part = { "artifactLocator" => perfecto_media_fullpath, "override" => true } parameters(request_part, "artifactType", artifact_type) parameters(request_part, "artifactName", artifact_name) request_part = request_part.to_json.to_s.gsub("=>", ":") # Debug: puts request_part form_data = [["requestPart", request_part], ["inputStream", File.open(file_path, "rb")]] request.set_form(form_data, "multipart/form-data") response = https.request(request) UI.(response.inspect) if response.code != "200" # Give error if upload failed. UI.user_error!("App upload failed!!! Reason : #{response}") end end |