Java API extending - add an existing file of Java File type to existing repository workspace
![]()
Peter Moraza (48●19●24)
| asked Aug 19 '13, 4:34 p.m.
edited Aug 20 '13, 9:51 a.m. by Tim Mok (6.6k●3●8)
Hello,
We are migrating files from our current repository solution to RTC 4.0.2, and I am in need of an example to convert a Java File type object to IFileItem. Snippet2.java appears to add a file to a repository workspace by creating a new file, but instead, I have a Java File path to an existing file, and I need to add that file to a repository workspace. Would I simply copy my Java File object to an array of bytes (byte[]) and pass to the VersionedContentManagerByteArrayInputStreamPovider constructor? How can I point to that file's path, or is it assumed that the file must exist in the local sandbox (i.e. Eclipse workspace where the command will be invoked)? Any assistance or examples would be much appreciated. Thanks!
Peter
|
3 answers
![]()
Yes, you need to read the file contents pass it to the
IFileContentManager.storeContent(...) |
![]()
Thanks Te-Hsin. I was actually able to add files to the repository workspace by converting the File to byte[]. I am able to add all file types with the exception of archive (i.e. .zip or .in my case, .bar) files. I'm experimenting with changing the IFileItem content type to allow those adds. It is currently set as follows. Any ideas what needs to change to add .bar, .jar or .zip files?
file.setContentType(IFileItem.CONTENT_TYPE_TEXT);
|