You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Oleg Kalnichevski <ol...@apache.org> on 2004/09/15 23:03:31 UTC

Re: need help to change charset when fileUpload using MultipartPostMethod

Bülent,

This is a well known issue. The problem is that the use of non-ASCII
characters in the content disposition header (the one that includes the
file name attribute) violates the MIME spec.

See the following bug reports for details

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=30420
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=24504

You can work the problem around by

(1) sub-classing FilePart and providing a custom implementation of the
sendDispositionHeader(OutputStream) method

(2) using Q-Codec to encode the file name

http://jakarta.apache.org/commons/codec/apidocs/org/apache/commons/codec/net/QCodec.html

Hope this helps

Oleg


On Wed, 2004-09-15 at 10:40,
 =?ISO-8859-1?Q?B=FClent_Turhan_\=28B.T.K.B.S.G.\=29?= wrote:
> hi, i need some help. How can i change default charset "ISO-8859-1" to "ISO-8859-9" ?
> i need this because my file name ( cmEvrakDTO.getFileName() below ) has turkish chars like I, Ü ,S Ç etc ..
> and when uploading these chars becomes "?" when reading in servlet side.
> 
> my simple code is :
> 
> 
> 		String dokURL = "http://localhost:9080/AkpostaWeb/UploadByteArrayedFileDuyuru";
> 
> 		HttpClient httpClient = new HttpClient();
> 
> 		MultipartPostMethod mPost = new MultipartPostMethod(dokURL);
> 		ByteArrayPartSource byteArrayPartSource =
> 			new ByteArrayPartSource(
> 				cmEvrakDTO.getFileName(),
> 				cmEvrakDTO.getFileContent());
> 
> 		FilePart fp = new FilePart(cmEvrakDTO.getFileName(), byteArrayPartSource);
> //  i wanna change charset here.
> 		mPost.addPart(fp);
> 		try {
> 			//POST
> 			int statusCode = httpClient.executeMethod(mPost);
> 		} catch (HttpException e) {
> 			// TODO Auto-generated catch block
> 			e.printStackTrace();
> 		} catch (IOException e) {
> 			// TODO Auto-generated catch block
> 			e.printStackTrace();
> 		}
> 
> 		mPost.releaseConnection();
> 
> 
> thx a lot..
> 
> Bülent
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> *************************************************************************************
> 01.09.2004 tarihinden itibaren @akbank.com.tr seklindeki e-posta mesajlari sistemimize ulasmayacaktir. Iletisimin aksamamasi için kullandiginiz e mail adreslerini isim.soyad@akbank.com  seklinde degistirmenizi rica ederiz.
> 
> Bu e-posta ve muhtemel eklerinde verilen bilgiler kisiye özel ve gizli olup, yalnizca mesajda belirlenen alici ile ilgilidir.Size yanlislikla ulasmissa lütfen göndericiye bilgi veriniz, mesaji siliniz ve içerigini baska bir kisiye açiklamayiniz, herhangi bir ortama kopyalamayiniz. Bu mesaj aksi sözlesme ile belirtilmedikçe herhangi bir finansal islem teklifi, alimi, satimi veya herhangi bir havalenin teyidi gibi bankacilik islemi yapilmasi amacini tasimamaktadir.Verilen tüm bilgilerin dogrulugu ve bütünlügünün garantisi verilmemekte olup, önceden bildirilmeksizin degistirilebilecektir.Bu mesajin içerigi Bankamizin resmi görüslerini yansitmayabileceginden Akbank T.A.S. hiçbir hukuki sorumlulugu kabul etmez.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org