java - image corrupted by FileUpload -
i need make http server recieving , sending images , text(less 100 characters) client. planning use json or google protocol buffer.
i studied "httpuploadserver" example in netty 4.0.6 package.
then, deleted in handler except things dealing multipart post requests.
here's part struggling with.
private void writehttpdata(interfacehttpdata data) { fileupload fileupload = (fileupload)data; try { file file = fileupload.getfile(); file.renameto(new file("c:\\savedfiles\\"+file.getname())); } catch (ioexception e) { e.printstacktrace(); } }
when call getfile(), gives me corrupted file. i've tested zip files, , images(png, jpeg). (btw. using postman add-on test server, wrong headers not problem)
is there way make right?
found answer on github
change
private static final httpdatafactory factory = new defaulthttpdatafactory(defaulthttpdatafactory.minsize);
to
private static final httpdatafactory factory = new defaulthttpdatafactory(false);
or
private static final httpdatafactory factory = new defaulthttpdatafactory(true);
for me setting true worked!
Comments
Post a Comment