Tuesday, March 15, 2011 at 12:00 AM.


on newObject (relpath, data, type=nil, adrmeta=nil, acl="public-read") {
		<<4/12/06; 4:37:34 AM by DW
			<<If type is nil, try to get the type from user.webserver, based on the extension.
		<<4/11/06; 9:33:36 AM by DW
	local (response);
	local (adrdata = s3.init ());
	local (apiUrl = adrdata^.accounts.[adrdata^.currentaccount].apiurl);
	if type == nil {
		local (extension = string.nthfield (relpath, ".", string.countfields (relpath, ".")));
		local (adrtype = @user.webserver.prefs.ext2MIME.[extension]);
		if defined (adrtype^) {
			type = adrtype^}
		else {
			type = "text/plain"}};
	response = s3.httpClient ("PUT", relpath, content:data, adrMeta:adrmeta, content_type:type, acl:acl);
	<<scratchpad.response = response
	return (apiUrl + relpath)};
bundle { //test code
	local (i, filetext = string.filledstring ("123456789 ", 1000));
	webbrowser.openurl (newObject ("/scripting/myServerFarm/test" + 1 + ".txt", string (this^), nil))}

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.