BytesChunkedIterator
Interfaz que han de implementar las clases que iteran sobre un churro de bytes,
bien sea un array de bytes (ByteArrayChunkedIterator) o sobre un InputStream (ByteStreamChunkedIterator)
Esta clase es de utilidad por ejemplo cuando un churro de bytes hay que enviarlo en paquetes (chunks)
por ejemplo a otro servidor (ej: subir ficheros a iw)
De esta forma, el cliente se abstrae de la complejidad de implementar el troceado del churro de entrada
Ejemplo de uso:
R01MContentDataAPI contentDataAPI = R01MClientFactory.getContentDataAPI(_userCtx,contentOid);
ChunkedIterator bytesIt = new ByteStreamChunkedIterator(is); // cambiar por new ByteArrayChunkedIterator(fileBytes) si en lugar de un InputStream se pasa un array de bytes
while (bytesIt.hasNext()) {
int offset = bytesIt.getOffset();
byte[] bytes = bytesIt.next();
contentDataAPI.uploadAttachmentFileChunk(documentOid,path,bytes,offset);
}
|