Search in sources :

Example 1 with FileNodeEndChunk

use of org.structr.cloud.message.FileNodeEndChunk in project structr by structr.

the class PushTransmission method sendFile.

/**
 * Splits the given file and sends it over the client connection. This method first creates a <code>FileNodeDataContainer</code> and sends it to the remote end. The file from disk is then
 * split into multiple instances of <code>FileChunkContainer</code> while being sent. To finalize the transfer, a <code>FileNodeEndChunk</code> is sent to notify the receiving end of the
 * successful transfer.
 *
 * @param client the client to send over
 * @param file the file to split and send
 * @param chunkSize the chunk size for a single chunk
 * @throws org.structr.common.error.FrameworkException
 * @throws java.io.IOException
 */
public static void sendFile(final CloudConnection client, final File file, final int chunkSize) throws FrameworkException, IOException {
    // send file container first
    FileNodeDataContainer container = new FileNodeDataContainer(file);
    client.send(container);
    // send chunks
    for (FileNodeChunk chunk : FileNodeDataContainer.getChunks(file, chunkSize)) {
        client.send(chunk);
    }
    // mark end of file with special chunk
    client.send(new FileNodeEndChunk(container.getSourceNodeId(), container.getFileSize()));
}
Also used : FileNodeEndChunk(org.structr.cloud.message.FileNodeEndChunk) FileNodeChunk(org.structr.cloud.message.FileNodeChunk) FileNodeDataContainer(org.structr.cloud.message.FileNodeDataContainer)

Example 2 with FileNodeEndChunk

use of org.structr.cloud.message.FileNodeEndChunk in project structr by structr.

the class SyncTransmission method sendFile.

/**
 * Splits the given file and sends it over the client connection. This method first creates a <code>FileNodeDataContainer</code> and sends it to the remote end. The file from disk is then
 * split into multiple instances of <code>FileChunkContainer</code> while being sent. To finalize the transfer, a <code>FileNodeEndChunk</code> is sent to notify the receiving end of the
 * successful transfer.
 *
 * @param client the client to send over
 * @param file the file to split and send
 * @param chunkSize the chunk size for a single chunk
 * @throws org.structr.common.error.FrameworkException
 * @throws java.io.IOException
 */
public static void sendFile(final CloudConnection client, final File file, final int chunkSize) throws FrameworkException, IOException {
    // send file container first
    FileNodeDataContainer container = new FileNodeDataContainer(file);
    client.send(container);
    // send chunks
    for (FileNodeChunk chunk : FileNodeDataContainer.getChunks(file, chunkSize)) {
        client.send(chunk);
    }
    // mark end of file with special chunk
    client.send(new FileNodeEndChunk(container.getSourceNodeId(), container.getFileSize()));
}
Also used : FileNodeEndChunk(org.structr.cloud.message.FileNodeEndChunk) FileNodeChunk(org.structr.cloud.message.FileNodeChunk) FileNodeDataContainer(org.structr.cloud.message.FileNodeDataContainer)

Aggregations

FileNodeChunk (org.structr.cloud.message.FileNodeChunk)2 FileNodeDataContainer (org.structr.cloud.message.FileNodeDataContainer)2 FileNodeEndChunk (org.structr.cloud.message.FileNodeEndChunk)2