Skip to content
treeder edited this page Mar 26, 2012 · 1 revision

Local Temporary Storage

Workers can access up to 10 GB of local/cloud temporary storage by using user_dir in the worker which will return a path to the directory that your worker has write access to. You can create directories and perform file operations just as you would in your app environment.

Here is a code snippet as an example:

class S3Worker < IronWorker::Base

  filepath = user_dir + "ironman.jpg"
  File.open(filepath, 'wb') do |fo|
    fo.write open("http://fitnessgurunyc.com/wp/wp-content/uploads/2010/12/ironman74.jpg").read
  end
  log "\nLocal 'user_dir' storage:"
  user_files = %x[ls #{user_dir}]
  log "#{user_files}"
end

You can find the full example here:

[IronWorker storage example](https://github.com/iron-io/iron_worker_examples/tree/master/ruby/s3_tester) 

Accessing Merged Files and Folders

Note that the user_dir directory also contains your code and other merged files. Any nested files that are merged in will appear at the top level. For example, merging a file such as the following:

merge "../site_stats/client.rb"

Will place it in the user_dir directory in IronWorker

user_dir/
  ...
  client.rb

Use Cases

Typical use cases might include:

  • downloading an image from S3, modifying it, and re-uploading it,
  • downloading a multi-megabyte log file, parsing it, and inserting it into a database,

Additional Capacity

There may be more local memory available depending on the type of server instance. If you need more capacity, please contact us and we can look to provide you with more local storage options.

Clone this wiki locally