سؤال

I'm successfully using VFS to download files from HTTP, SFTP, FTP, etc. I need to get the content type of the file and I've run into a strange thing that I'm not sure why is happening.

FileObject file = vfs.resolveFile(uri) ;
FileContent content = remote.getContent();

InputStream source = content.getInputStream();
ByteArrayOutputStream target = new ByteArrayOutputStream();
copy(source, target);

content.getSize(); // HACK: Prevents null-pointer in next line
String type = content.getContentInfo().getContentType();

If I remove the call to getSize, content.getContentInfo will return null. Why is this? Am I missing something?

هل كانت مفيدة؟

المحلول

As @Sam-Rad wrote, it is fixed in trunk (upcoming VFS 2.1):

https://issues.apache.org/jira/browse/VFS-427

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top