1

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?

Svish
  • 152,914
  • 173
  • 462
  • 620

1 Answers1

1

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

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

eckes
  • 10,103
  • 1
  • 59
  • 71