public UploadedData upload(FileItem formFile) {
if (formFile == null) {
return null;
}
List<Object> models = new ArrayList<Object>();
UploadedData data = new UploadedData();
models.add(data);
data.setKey(Datastore.allocateId(d));
data.setFileName(formFile.getShortFileName());
data.setLength(formFile.getData().length);
byte[] bytes = formFile.getData();
byte[][] bytesArray = ByteUtil.split(bytes, FRAGMENT_SIZE);
Iterator<Key> keys =
Datastore
.allocateIds(data.getKey(), f, bytesArray.length)
.iterator();
for (int i = 0; i < bytesArray.length; i++) {
byte[] fragmentData = bytesArray[i];
UploadedDataFragment fragment = new UploadedDataFragment();
models.add(fragment);