Monday, November 08, 2010 at 12:01 AM.

system.verbs.apps.s3.getObjectMetadata

on getObjectMetadata (path, adrmetadata, flmessages=false) {
	<<Changes
		<<5/6/07; 1:02:21 PM by DW
			<<Created. Get everything about the object but the data. This is going to be very useful.
	local (adrdata = s3.init (), response);
	local (apiUrl = adrdata^.accounts.[adrdata^.currentaccount].apiurl);
	if not (path beginswith "/") {
		path = "/" + path};
	if flmessages {
		msg ("s3.getObjectMetadata " + path)};
	response = s3.httpClient ("HEAD", path);
	if flmessages {
		msg ("")};
	scratchpad.response = response;
	adrmetadata^ = response.headers;
	if response.flerror {
		return (false)};
	if not defined (response.headers.["Content-Length"]) { //indicates it was not found
		return (false)};
	if not defined (response.headers.["Last-Modified"]) { //indicates it was not found
		return (false)};
	return (true)};
bundle { //test code
	if getObjectMetadata ("/scriptingImages/2005/09/25/cheerios.gif", @scratchpad.cheeriosdata, true) {
		edit (@scratchpad.cheeriosdata)}}



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.