if (uploadIds == null)
return;
StringBuilder value = new StringBuilder();
value.append("{\n upload : {");
for (int i = 0; i < uploadIds.length; i++) {
UploadResource upResource = service.getUploadResource(uploadIds[i]);
if (upResource == null)
continue;
if (upResource.getStatus() == UploadResource.FAILED_STATUS) {
UploadLimit limit = service.getUploadLimits().get(uploadIds[i]);
value.append("\n \"").append(uploadIds[i]).append("\": {");
value.append("\n \"status\":").append('\"').append("failed").append("\",");
value.append("\n \"size\":").append('\"').append(limit.getLimit()).append("\",");
value.append("\n \"unit\":").append('\"').append(limit.getUnit()).append("\"");
value.append("\n }");
continue;
}
double percent = 100;
if (upResource.getStatus() == UploadResource.UPLOADING_STATUS) {
percent = (upResource.getUploadedSize() * 100) / upResource.getEstimatedSize();
}
value.append("\n \"").append(uploadIds[i]).append("\": {");
value.append("\n \"percent\":").append('\"').append((int) percent).append("\",");
String fileName = EntityEncoder.FULL.encode(upResource.getFileName());
value.append("\n \"fileName\":").append('\"').append(encodeName(fileName)).append("\"");
value.append("\n }");
if (i < uploadIds.length - 1)
value.append(',');
}