protected Request createCloseRequest(Path path) { Request request = new Request(Command.CREATE_CLOSE); request.addArg("class", getType()); request.addArg("filename", getFilename()); request.addArg("size", String.valueOf(getFile().length())); request.addArg("fid", path.getFid()); request.addArg("devid", path.getDevid()); request.addArg("path", path.getPath()); if (username != null) { request.addArg("username", getUsername()); } if (contentType != null) { request.addArg("content_type", getContentType()); } return request; }
/* * @see com.painiu.pnfs.File#store() */ public void store() throws PNFSException { Response rsp = createOpen(); List<Path> paths = parsePaths(rsp); Path path = PNFS.httpPutFile(file, paths); if (path == null) { throw new PNFSException("Failed to send file to YPFS storage node"); } try { createClose(path); } catch (PNFSException e) { // rollback PNFS.httpDeleteFile(path.getPath()); throw e; } }