SenseNet / sn-client-dotnet

A .Net client for sensenet that makes it easy to use the REST API of the Content Repository.
https://www.sensenet.com/
GNU General Public License v2.0
7 stars 16 forks source link

Error when using Content.UploadAsync to upload file with chinese file name #5

Closed frankyuan closed 6 years ago

frankyuan commented 7 years ago

I'm trying to upload file with Chinese file name to sensenet using Content.UploadAsync. For some file names, such as 运维管理.txt , there is an exception "Specified value has invalid Control characters. Parameter name: value". If rename to another file name, maybe it works well. Seems like encode issue. Could you give me some suggestions?

I'm trying to upload file with Chinese file name to sensenet using Content.UploadAsync. For some file names, such as 运维管理.txt , there is an exception "Specified value has invalid Control characters. Parameter name: value". If rename to another file name, maybe it works well. Seems like encode issue. Could you give me some suggestions?

My code:

using (var stream = new FileStream(localFilePath, FileMode.Open)) { await Content.UploadAsync(parentPath, fileName, stream, "File"); } StackTrace:

at System.Net.WebHeaderCollection.CheckBadChars(String name, Boolean isHeaderValue)
at System.Net.WebHeaderCollection.Add(String name, String value) at SenseNet.Client.RESTCaller.CreateChunkUploadWebRequest(String url, ServerContext server, UploadData uploadData, String boundary, Stream& requestStream) in sn-client-dotnet-master\sn-client-dotnet-master\src\SenseNet.Client\RESTCaller.cs:line 620 at SenseNet.Client.RESTCaller.d__23.MoveNext() in sn-client-dotnet-master\sn-client-dotnet-master\src\SenseNet.Client\RESTCaller.cs:line 490

tusmester commented 7 years ago

(We should update the original SO question when this is solved.)

It is possible that we should handle this on both client and server side (meaning a modification should be made in the main sensenet repo too), to make the server (UploadAction) understand both the filename and filename*. properties of the Content-Disposition header.

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition

tusmester commented 6 years ago

Thank you @frankyuan and @drwatson1 for your patience, we released the fix in v1.1.1.