It's all about the answers!

Ask a question

Fetch the first n bytes of a file inside a Change Set in a RTC precondition


Martin Wassermann (13864044) | asked Sep 22 '15, 5:06 a.m.
edited Sep 22 '15, 5:12 a.m.
 Hi

I plan to develop a RTC precondition that checks, whether a file that is delivered is a binary file or not. Therefore I would like to read the first n bytes of the files and then look, if it uses mainly usual characters or not.

I already can fetch the content of the files, by getting all IFileItem of the change set and then fetch the content with the IServerSideVersionedContentService:
IServerSideVersionedContentService contentService =
  (IServerSideVersionedContentService) getService(IServerSideVersionedContentService.class);
ByteArrayOutputStream out = new ByteArrayOutputStream();
contentService.fetchContentTrusted(file,content.getHash(), out);

But with the method fetchContentTrusted I get always the whole file. What I would need, due to performance issues, is only to fetch the first n bytes. Is there a way to get only the first n bytes instead of the whole content?

Thanks and regards

Martin

Be the first one to answer this question!


Register or to post your answer.