Skip to content

Commit

Permalink
Modified README to include information about 'uploading' files from a…
Browse files Browse the repository at this point in the history
… script
  • Loading branch information
eadz committed Jun 9, 2008
1 parent 1e46a77 commit dfc4ada
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,13 @@ The following example shows how to upload a file from a script.
require 'action_controller'
require 'action_controller/test_process.rb'

@attachable = AttachmentMetadataModel.new(:uploaded_data => ActionController::TestUploadedFile.new(path, mimetype))
@attachable.save

This will "upload" the file at path and create the new model.
path = "./public/images/x.jpg"

mimetype is a string like "image/jpeg". One way to get the mimetype for a given file on a UNIX system
# mimetype is a string like "image/jpeg". One way to get the mimetype for a given file on a UNIX system
# mimetype = `file -ib #{path}`.gsub(/\n/,"")

mimetype = `file -ib #{path}`.gsub(/\n/,"")
mimetype = "image/jpeg"

# This will "upload" the file at path and create the new model.
@attachable = AttachmentMetadataModel.new(:uploaded_data => ActionController::TestUploadedFile.new(path, mimetype))
@attachable.save

0 comments on commit dfc4ada

Please sign in to comment.