Search in sources :

Example 6 with File

use of org.structr.dynamic.File in project structr by structr.

the class FileNodeDataContainer method persistTemporaryFile.

/**
 * Renames / moves the temporary file to its final location. This method is called when the cloud service recevies a <code>FileNodeEndChunk</code>.
 *
 * @param finalPath the final path of this file
 * @return whether the renaming/moving was successful
 */
public boolean persistTemporaryFile(String finalPath) throws IOException {
    boolean ret = false;
    if (temporaryFile != null) {
        final java.io.File finalFile = new java.io.File(finalPath);
        final Path source = temporaryFile.toPath();
        final Path dest = finalFile.toPath();
        // create parent directories
        finalFile.mkdirs();
        // move file from tmp to final destination
        Files.move(source, dest, StandardCopyOption.REPLACE_EXISTING);
    }
    return (ret);
}
Also used : Path(java.nio.file.Path) File(org.structr.dynamic.File)

Aggregations

File (org.structr.dynamic.File)6 NodeInterface (org.structr.core.graph.NodeInterface)4 NodeDataContainer (org.structr.cloud.message.NodeDataContainer)3 RelationshipDataContainer (org.structr.cloud.message.RelationshipDataContainer)3 List (java.util.List)2 FileNodeDataContainer (org.structr.cloud.message.FileNodeDataContainer)2 RelationshipInterface (org.structr.core.graph.RelationshipInterface)2 Path (java.nio.file.Path)1 LinkedHashSet (java.util.LinkedHashSet)1 DatabaseService (org.structr.api.DatabaseService)1 NotFoundException (org.structr.api.NotFoundException)1 Node (org.structr.api.graph.Node)1 Relationship (org.structr.api.graph.Relationship)1 Delete (org.structr.cloud.message.Delete)1 End (org.structr.cloud.message.End)1 GraphObject (org.structr.core.GraphObject)1 ModificationEvent (org.structr.core.graph.ModificationEvent)1 NodeFactory (org.structr.core.graph.NodeFactory)1 RelationshipFactory (org.structr.core.graph.RelationshipFactory)1 Tx (org.structr.core.graph.Tx)1