Can I upload a file to S3 from the server-side scripting language?
'd like to take a file on an Adobe Media Server and upload it to S3 preferably by using the Server-Side Actionscript API.
I've found that the LoadVars class can do HTTP requests, to some extent.
The LoadVars.send() says:
"All enumerable variables in the myLoadVars object are concatenated into a string that is posted to the URL by using the HTTP POST method."
I'm not sure of what, exactly, this means, or where it puts this string, but I'm guessing it inserts it into the url as a querystring. I don't think S3 accepts objects like this.
Is it possible to accomplish what I want to do with the server-side scripting language?
The most important thing, besides getting the file on S3, is to get some sort of a notification that it's done so that I can tell my Flash client that it has been uploaded. This means that the API needs to be be aware of, or discover that the file has been uploaded.
I'm experimenting with this:
var lv = new LoadVars();
lv.onHTTPStatus = function(httpStatus) {
this.httpStatus = httpStatus;
if(httpStatus < 100) {
this.httpStatusType = "flashError";
trace(this.httpStatusType);
} else if(httpStatus < 200) {
this.httpStatusType = "informational";
trace(this.httpStatusType);
} else if(httpStatus < 300) {
this.httpStatusType = "successful";
trace(this.httpStatusType);
} else if(httpStatus < 400) {
this.httpStatusType = "redirection";
trace(this.httpStatusType);
} else if(httpStatus < 500) {
this.httpStatusType = "clientError";
trace(this.httpStatusType);
} else if(httpStatus < 600) {
this.httpStatusType = "serverError";
trace(this.httpStatusType);
}
}
var file = new File("/streams/_definst_/"+newName+".flv");
file.open("utf8","read");
lv.file = file.readAll();
lv.contentType = "application/octet-stream";
if(lv.sendAndLoad("http://ct.recorder.s3.amazonaws.com","POST")){
trace("Success");
}else{trace("Failure"); }
When I run this, I get Failure, and no trace from the onHTTPStatus listener.
Currently, I'm using a C# process to watch the directory, and when the file is "saved", it'll upload it to S3 and send a POST to another server containing metadata about the file, which the front end then polls until it finds this metadata, at which point it uses it to play the completed file from cloud storage.
