Class: CloudConvert::SignedUrl

Inherits:
Object
  • Object
show all
Defined in:
lib/cloudconvert/signed_url.rb

Class Method Summary collapse

Class Method Details

.sign(base, signing_secret, job, cache_key = nil) ⇒ String

Returns The signed URL.

Parameters:

  • base (String)

    The base from for your signed URL settings.

  • signing_secret (String)

    The signing secret from for your signed URL settings.

  • job (Hash)

    The job to create the signed URL for

  • cache_key (String) (defaults to: nil)

    Allows caching of the result file for 24h

Returns:

  • (String)

    The signed URL



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/cloudconvert/signed_url.rb', line 9

def sign(base, signing_secret, job, cache_key = nil)
  url = base

  url += "?job=" + Base64.urlsafe_encode64(job.to_json, padding: false)

  unless cache_key.nil?
    url += "&cache_key=" + cache_key
  end

  url += "&s=" + OpenSSL::HMAC.hexdigest("SHA256", signing_secret, url)

  url
end