use of org.polymap.service.fs.spi.IContentFile in project polymap4-core by Polymap4.
the class FsContentProvider method createNew.
/**
* Creates a new file for the given input.
* @param fsFolder
*
* @param newName
* @param in
* @return Newly created {@link FsFile} reflecting the created file.
*/
public IContentFile createNew(FsFolder folder, String newName, InputStream in) throws IOException, NotAuthorizedException, BadRequestException {
assert newName != null;
OutputStream fileOut = null;
try {
File f = new File(folder.getDir(), newName);
boolean isNewFile = !f.exists();
fileOut = new FileOutputStream(f);
IOUtils.copy(in, fileOut);
// reload folder if file was created
if (isNewFile) {
getSite().invalidateFolder(folder);
}
return new FsFile(folder.getPath(), this, f);
} finally {
IOUtils.closeQuietly(fileOut);
}
}
Aggregations