Simulating file uploads in your scripts or from console can be done really simple using Rail’s ActionController::TestUploadedFile fromaction_pack.
Example code:
Excerpt from ActionController::TestUploadedFile’s comments:
Essentially generates a modified Tempfile object similar to the object
you’d get from the standard library CGI module in a multipart
request. This means you can use an ActionController::TestUploadedFile
object in the params of a test request in order to simulate
a file upload.
No comments:
Post a Comment