Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

File Handle

Chiho Sin edited this page Aug 18, 2016 · 1 revision

Use FileTemplate to handle file upload, delete, update , fetch, and status query.

Setting Properties

You can custom handle template by setting properties.

Setting Description
setSameRackCount(1) Number of replica in other servers in the same rack.
setDiffRackCount(1) Number of replica in other racks in the same data center.
setDiffDataCenterCount(1) Number of replica in other data centers.
setTimeToLive(300) Default time to file live in server (in second).
setDataCenter("DefaultCenter") Default handle data center from volume.
setCollection("Test") Default handle collection from volume.
setUsingPublicUrl(true) Used public location to connected.
setLoadBalance(true) Load balance at get location to connected.

File Handle

File handle is base on InputStream.

// Get file stream
template.getFileStream("3,392842b2");
// Query file status
template.getFileStatus("3,392842b2");
// Get file url
template.getFileUrl("3,392842b2");
// Save file by stream
template.saveFileByStream("test.txt",
                new ByteArrayInputStream("@saveFileByStream".getBytes()));
// Delete file
template.deleteFile("3,392842b2");
// Update file
template.updateFileByStream("3,392842b2", "test.png", imageFile);

Clone this wiki locally