mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
A new flavor of createFile. Slightly slower. Significantly safer.
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3277 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -92,6 +92,36 @@ class FileContentImpl implements FileContent, Serializable
|
||||
SuperRepository.GetInstance().getSession().save(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize with the given content.
|
||||
* @param id
|
||||
* @param content
|
||||
*/
|
||||
public FileContentImpl(long id, File content)
|
||||
{
|
||||
fID = id;
|
||||
fRefCount = 1;
|
||||
// Initialize the contents.
|
||||
try
|
||||
{
|
||||
OutputStream out = getOutputStream();
|
||||
InputStream in = new FileInputStream(content);
|
||||
byte [] buff = new byte[8192];
|
||||
int count;
|
||||
while ((count = in.read(buff)) != -1)
|
||||
{
|
||||
out.write(buff, 0, count);
|
||||
}
|
||||
out.close();
|
||||
in.close();
|
||||
}
|
||||
catch (IOException ie)
|
||||
{
|
||||
throw new AVMException("I/O Error.", ie);
|
||||
}
|
||||
SuperRepository.GetInstance().getSession().save(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy constructor, sort of.
|
||||
* @param other The content to copy from.
|
||||
|
Reference in New Issue
Block a user