Discussion:
posting large files
Ding, Howard Adrian
2012-12-13 19:17:29 UTC
Permalink
Hi,

I'm curious if there are any recommended ways to post large files (directly, not through a form) with Mechanize. E.g. I have something like the following:

content = File.open(file_path, 'rb') { |f| f.read }
self.client.post(file_url(bit_file), content, ingest_headers(bit_file, file_path, opts[:path]))

but this requires reading the entire content of the file into memory to make the post. I see that on the GET side there is a method called download which appears to function like a GET but to write the response body directly to a file without having to have it all in memory at once, and I guess I'm looking to see if there is anything similar for posting, as I may come up against situations where I need to post files that are significantly larger than my machines memory.

Thanks,
Howard

Howard Ding
Visiting Research Programmer
135 Grainger Engineering Library
217-300-1763 / ***@illinois.edu

Loading...