0

Fileupload, Media, writing to file system

asked 2009-12-07 14:18:05 +0800

dastultz gravatar image dastultz
797 8

Hello, I want to use Fileupload to get a file and write it a file on the local server. The Files.copy method seems handy for this. It seems Media.isBinary() uses the file extension to determine text from binary. So something like an SQL file appears to be binary. In any case I'd like to write the file as binary. I can't call media.getStreamData() if it appears to be text (it throws an exception). I don't want to write the file using a reader (media.getReaderData()) because the file may be binary (wrong file extension). Also Files.copy takes a reader and a character set. I don't know the character set nor do I want to risk character translation problems. I just want to get the raw data in a file.

Is it possible to get an InputStream from Media regardless of what Media thinks is in the file?

Thanks.

/Daryl

delete flag offensive retag edit

1 Reply

Sort by ยป oldest newest

answered 2009-12-08 08:39:08 +0800

dastultz gravatar image dastultz
797 8

Solved it. Specify "native" ("alwaysNative" = true) to get it as binary with no media type matching.

/Daryl

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2009-12-07 14:18:05 +0800

Seen: 388 times

Last updated: Dec 08 '09

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More