Take the 2-minute tour ×

I've successfully followed Soundcloud's API documentation but hit an error that's got me stuck.

When uploading / posting a file using their example I have no trouble when I hard code a file on my local machine. What I really want to do is transfer files stored on S3. This kept failing with an Errno::ENOENT - No such file or directory error. Open-URI is included and I tested it by hardcoding a file available to the public on another server and it still fails. So I don't feel the problem is with S3 or my generate_secure_s3_url for that reason and because I successfully use my generate_secure_s3_url elsewhere.

My code is as follows, can anyone help?

def product_tracks_to_soundcloud(access_token)
  require 'soundcloud'
  require 'open-uri'
  # create a client object with access token
  client = Soundcloud.new(:access_token => access_token)

    self.producttracklistings.each do |pt|
        filebase = URI.encode(pt.track.track_file_name, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))
        fileurl = generate_secure_s3_url(filebase)
        # upload an audio file
    track = client.post('/tracks', :track => {
      :title => pt.track.name,
      :asset_data => File.new(fileurl, 'rb')
share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

Ok, managed to figure this one out myself and it's annoyingly simply. Firstly at no point in the above am I actually calling upon Open-URI. Once I sussed that, it was then just a case of ammending this:

:asset_data => File.new(fileurl, 'rb')

to this:

:asset_data => open(fileurl)

I hope that is of help to others.

share|improve this answer
add comment

Your Answer


