int countMeta = 0;
int state = 0;
// [A] First parse all the parts out of the POST request and message body
// -> bucket name is still encoded in a Host header
S3AuthParams params = new S3AuthParams();
List<S3MetaDataEntry> metaSet = new ArrayList<S3MetaDataEntry>();
S3PutObjectInlineRequest engineRequest = new S3PutObjectInlineRequest();
engineRequest.setBucketName( bucket );
// -> the last body part contains the content that is used to write the S3 object, all
// other body parts are header values
while( null != (oneLine = br.readLine()))
{
if ( oneLine.startsWith( lastBoundary ))
{
// -> this is the data of the object to put
if (0 < temp.length())
{
value = temp.toString();
temp.setLength( 0 );
engineRequest.setContentLength( value.length());
engineRequest.setDataAsString( value );
}
break;
}
else if ( oneLine.startsWith( boundary ))
{
// -> this is the header data
if (0 < temp.length())
{
value = temp.toString().trim();
temp.setLength( 0 );
//System.out.println( "param: " + name + " = " + value );
if (name.equalsIgnoreCase( "key" )) {
engineRequest.setKey( value );
}
else if (name.equalsIgnoreCase( "x-amz-acl" )) {
engineRequest.setCannedAccess( value );
}
else if (isMetaTag) {
S3MetaDataEntry oneMeta = new S3MetaDataEntry();
oneMeta.setName( metaName );
oneMeta.setValue( value );
metaSet.add( oneMeta );
countMeta++;
metaName = null;
}
// -> build up the headers so we can do authentication on this POST
HeaderParam oneHeader = new HeaderParam();
oneHeader.setName( name );
oneHeader.setValue( value );
params.addHeader( oneHeader );
}
state = 1;
}
else if (1 == state && 0 == oneLine.length())
{