Monday, March 14, 2011 at 3:24 AM.

myServerFarmSuite.uploadFolderToS3

on uploadFolderToS3 (folder) {
	<<Changes
		<<3/14/11; 2:23:53 AM by DW
			<<Updated to shorten S3 path. There's a severe limit, and we weren't being conservative.
		<<12/10/10; 10:18:25 AM by DW
			<<Created. 
	local (adrdata = myServerFarmSuite.init (), f, pc = file.getpathchar (), ctfiles = 0, ctbytes = 0);
	local (baseS3path = "/scripting/farm/" + adrdata^.prefs.myName + "/", startticks = clock.ticks ());
	<<s3.newobject (bases3path + "test2.txt", string (clock.now ()))
	fileloop (f in folder, infinity) {
		if file.filefrompath (f) != ".DS_Store" {
			local (filedata = string (file.readwholefile (f)));
			local (relpath = string.replaceall (string.delete (f, 1, sizeof (folder)), pc, "/"));
			msg (file.filefrompath (f));
			s3.newObject (baseS3path + relpath, string (filedata));
			ctfiles++;
			ctbytes = ctbytes + file.size (f)}};
	log2.add ("myServerFarm", "S3", "Uploaded " + ctfiles + " file(s) with " + string.gigabytestring (ctbytes) + " to " + baseS3path + ".", startticks)};
bundle { //test code
	local (folder = myServerFarmSuite.getMyFolder () + "Nightly Backup" + file.getpathchar ());
	uploadFolderToS3 (folder)}



This listing is for code that runs in the OPML Editor environment. I created these listings because I wanted the search engines to index it, so that when I want to look up something in my codebase I don't have to use the much slower search functionality in my object database. Dave Winer.