heroxav
heroxav

Reputation: 1467

HTTParty: Upload files

How would I do the following curl call using HTTParty?

$ curl -u [email protected] -F [email protected] -F 'data={"title":"Android Key","alias":"release", "key_pw":"90123456","keystore_pw":"78901234"}' https://build.phonegap.com/api/v1/keys/android

Here is what I currently have:

HTTParty.post("https://build.phonegap.com/api/v1/keys/android?auth_token=#{phonegap_token}", query: { keystore: file }, body: { data: {
    title: 'Android Key',
    alias: '...',
    key_pw: '...',
    keystore_pw: '...'
} }, format: :plain)

file is a Tempfile object which I fetched from the cloud storage where the file is located.

I want to pass a file which has been uploaded using Carrierwave and stored using Fog. Do I have to fetch it first from the URL?

Upvotes: 1

Views: 3011

Answers (1)

GorillaApe
GorillaApe

Reputation: 3641

I am not sure if it is going to work however you can try:

HTTParty.post("https://build.phonegap.com/api/v1/keys/android",  
  body: { 
    data: {
      title: 'Android Key',
      alias: '...',
      key_pw: '...',
      keystore_pw: '...'
    }.to_json,
  keystore: File.read(file)
  })

Upvotes: 1

Related Questions