// Is it really necessary to include the file list here?
ManifestElement[] elements = BaseManifestPutter.flatten(manifestElements);
fs.putSingle("DefaultName", defaultName);
for(int i=0;i<elements.length;i++) {
String num = Integer.toString(i);
ManifestElement e = elements[i];
String mimeOverride = e.getMimeTypeOverride();
SimpleFieldSet subset = new SimpleFieldSet(false);
FreenetURI tempURI = e.getTargetURI();
subset.putSingle("Name", e.getName());
if(tempURI != null) {
subset.putSingle("UploadFrom", "redirect");
subset.putSingle("TargetURI", tempURI.toString());
} else {
Bucket origData = e.getData();
Bucket data = origData;
if(data instanceof DelayedFreeBucket) {
data = ((DelayedFreeBucket)data).getUnderlying();
} else if(data instanceof DelayedFreeRandomAccessBucket) {
data = ((DelayedFreeRandomAccessBucket)data).getUnderlying();
}
subset.put("DataLength", e.getSize());
if(mimeOverride != null)
subset.putSingle("Metadata.ContentType", mimeOverride);
// What to do with the bucket?
// It is either a persistent encrypted bucket or a file bucket ...
if(data == null) {
Logger.error(this, "Bucket already freed: "+e.getData()+" for "+e+" for "+e.getName()+" for "+identifier);
} else if(data instanceof FileBucket) {
subset.putSingle("UploadFrom", "disk");
subset.putSingle("Filename", ((FileBucket)data).getFile().getPath());
} else if (data instanceof PaddedEphemerallyEncryptedBucket || data instanceof NullBucket || data instanceof PersistentTempFileBucket || data instanceof TempBucketFactory.TempBucket || data instanceof EncryptedRandomAccessBucket) {
subset.putSingle("UploadFrom", "direct");