lib/cdnconnect_api.rb in cdnconnect-api-0.3.2 vs lib/cdnconnect_api.rb in cdnconnect-api-0.3.3

- old
+ new

@@ -23,11 +23,11 @@ ## # Used to easily interact with CDN Connect API. class APIClient @@application_name = 'cdnconnect-api-ruby' - @@application_version = '0.3.2' + @@application_version = '0.3.3' @@user_agent = @@application_name + ' v' + @@application_version @@api_host = 'https://api.cdnconnect.com' @@api_version = 'v1' ## @@ -213,10 +213,11 @@ # Build the data that gets sent in the POST request post_data = build_post_data(:destination_path => destination_path, :destination_file_name => options[:destination_file_name], :queue_processing => options.fetch(:queue_processing, true), + :create_upload_url => options.fetch(:create_upload_url, true), :webhook_url => options[:webhook_url], :webhook_format => options[:webhook_format]) # Build the request to send to the API # Uses the Faraday: https://github.com/lostisland/faraday @@ -248,13 +249,10 @@ @logger.error(upload_response.body) # put the upload url back in the list # of prefetched urls so it can be reused set_prefetched_upload_url(destination_path, upload_url) - - # take a breath - sleep 1.5 else # successful upload, clear out the active upload queue # and remove uploaded files from the upload queue successful_upload_attempt(destination_path) @@ -291,20 +289,24 @@ # post_data will contain all of the data that gets sent post_data = {} # have the API also create the next upload url - post_data[:create_upload_url] = 'true' + if options[:create_upload_url] == true + post_data[:create_upload_url] = 'true' + @logger.debug(" - create_upload_url") + end # the set what the file name will be. By default it will be named the same as # the uploaded file. This will only work for single file uploads. post_data[:destination_file_name] = options[:destination_file_name] # Processing of the data can be queued. However, an `queue_processing` response # will not contain any information about the data uploaded. if options[:queue_processing] == true post_data[:queue_processing] = 'true' + @logger.debug(" - queue_processing") end # send with the post data the webhook_url if there is one if options[:webhook_url] != nil post_data[:webhook_url] = options[:webhook_url] @@ -615,11 +617,9 @@ elsif i > 2 @logger.error("Too many get_upload_url attempts") return response end @logger.error(response.body) - # take a breath - sleep 1.5 i += 1 end while i <= 3 end