Getting IFileContent for > 32kb files?
I'm trying to modify files in RTC, but I'm having trouble getting the IFileContent. I'm trying to get it as follows:
final FileInputStream stream = ...; AbstractVersionedContentManagerInputStreamProvider streamProvider = new AbstractVersionedContentManagerInputStreamProvider() { public void dispose() throws IOException, TeamRepositoryException {} public InputStream getInputStream(int i) throws IOException, TeamRepositoryException { return stream; } public InputStream wrapInputStream(InputStream in) throws IOException, TeamRepositoryException { return in; } }; IFileContentManager fileContentManager = FileSystemCore.getContentManager(repo); IFileContent content = fileContentManager.storeContent( encoding, // I've tried "UTF-8" and null delimiter, // I've tried both PLATFORM and NONE streamProvider, fileItem.getContent().getContentHash(), monitor); } This works fine if the file is less than 32k. Above 32k, I get the following: com.ibm.team.repository.common.transport.TeamServiceException: CRJAZ0099I When accessing the URL "https://MYSERVER:9443/ccm/service/com.ibm.team.filesystem.common.IFileContentService/content?hashcode=kEzIGNp_gznMXqJq5J7H99M7vKBPY5AuqcK81gElMqc&lineDelimiter=" the following HTTP error occurred: "Bad file descriptor" at com.ibm.team.repository.transport.client.ClientHttpUtil.executePrimitiveRequest(ClientHttpUtil.java:1192) at com.ibm.team.repository.transport.client.ClientHttpUtil.executeHttpMethod(ClientHttpUtil.java:328) at com.ibm.team.repository.transport.client.ClientHttpUtil.executeHttpMethod(ClientHttpUtil.java:290) at com.ibm.team.repository.transport.client.ClientHttpUtil.executeHttpMethod(ClientHttpUtil.java:204) at com.ibm.team.scm.client.content.BasicVersionedContentManager.executeMethod(BasicVersionedContentManager.java:446) [snip] Caused by: java.io.IOException: Bad file descriptor at java.io.FileInputStream.readBytes(Native Method) at java.io.FileInputStream.read(FileInputStream.java:220) at com.ibm.team.scm.client.internal.content.MonitoredInputStream.read(MonitoredInputStream.java:80) [snip] What do I need to do to upload big files? |
One answer
After a lot more poking at it, I've found that the following steps occur:
1) storeContent calls AVCMISP.getInputStream(1) 2) storeContent creates a byte array and reads the stream into it 2a) If the stream fits (< 32k), the byte array is wrapped in a stream and passed to AVCMISP.wrapInputStream(), and life is good 2b) If the stream doesn't fit, it's closed. 3b) AVCMISPgetInputStream(2) is called, passed to AVCMISP.wrapInputStream, and read from. I was receiving "Bad file descriptor" because my getInputStream(2) returned the already-closed stream, and it was trying to read from it. Now, I'm opening 2 copies of the stream and I've rigged up getInputStream to return the different copies. It's really ugly, but everything seems to be working fine. |
Your answer
Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.