Can't upload filename with special character to google drive REST

前端 未结 2 1290
有刺的猬
有刺的猬 2021-01-16 22:56

I\'m getting error when I try to upload a file to google drive api with my web application and the file has an character with accent, like for example \'ç\'.

I\'m up

相关标签:
2条回答
  • 2021-01-16 23:21

    Following the peleyal's commentary I solved my problem. I'm still using rest calls and not drive api, but I checked out the drive api source code and find out that they are using the HttpRequestMessage class. Changing my code from WebRequest to HttpRequestMessage solved the problem:

    var request = new HttpRequestMessage(HttpMethod.Post, uri);
    string strData = new JavaScriptSerializer().Serialize(jsonObject);
    
    var content = new StringContent(strData, Encoding.UTF8, "application/json");
    content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json");
    request.Content = content;
    
    0 讨论(0)
  • 2021-01-16 23:21

    Why don't you use the Google APIs .NET client library? As you can see in our Media page we support resumable media upload which is very easy to use, and will handle server errors for you.

    0 讨论(0)
提交回复
热议问题