-
Notifications
You must be signed in to change notification settings - Fork 13
Local disk 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)
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
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,
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.