r01f.io
Interface BytesChunkedIterator
- All Superinterfaces:
- java.io.Closeable, java.util.Iterator<byte[]>
- All Known Implementing Classes:
- ByteArrayChunkedIterator, ByteStreamChunkedIterator
public interface BytesChunkedIterator
- extends java.util.Iterator<byte[]>, java.io.Closeable
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);
}
| Methods inherited from interface java.util.Iterator |
hasNext, next, remove |
| Methods inherited from interface java.io.Closeable |
close |
getOffset
int getOffset()