I want to add file properties like name when making this call.
我想在进行此调用时添加名称等文件属性。
var request = (HttpWebRequest)WebRequest.Create("https://www.googleapis.com/upload/drive/v3/files");
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.MediaType = "text/plain";
request.Headers.Add(string.Format("Authorization: Bearer {0}", oAuthToken.AccessToken));
//request.Accept = "text/plain";
string tokenRequestBody = string.Format("this content goes inside the file that is created");
byte[] bytes = Encoding.ASCII.GetBytes(tokenRequestBody);
request.ContentLength = bytes.Length;
using (var requestStream = request.GetRequestStream())
{
requestStream.Write(bytes, 0, bytes.Length);
}
var response = request.GetResponse();
Now the file is being created without any filename and properties. It is passing authentication and file is being created and when we download the file and change the file extension we can see the content inside the file. But I want to send some file properties along with the request.
现在创建的文件没有任何文件名和属性。它正在传递身份验证并正在创建文件,当我们下载文件并更改文件扩展名时,我们可以看到文件中的内容。但我想发送一些文件属性和请求。
How to construct it and send for the POST method? Any help would be appreciated.
如何构造它并发送POST方法?任何帮助,将不胜感激。
Thank you.
谢谢。
Susarla Nikhilesh
Susarla Nikhilesh
1 个解决方案
#1
0
1:/ multi upload (ex: 5Mb/part)
2:/ Let write new sdk using new httprequest then you can do it (write file stream to network stream)
Note: all lib (maybe) httprequest using memory stream and write data to network stream then the speed result is speed of DISK to RAM (file stream to memory stream)
1:/多上传(例如:5Mb /部分)2:/让我们使用新的httprequest写新sdk然后就可以了(将文件流写入网络流)注意:所有lib(可能)httprequest使用内存流并写入数据到网络流然后速度结果是DISK到RAM的速度(文件流到内存流)
#1
0
1:/ multi upload (ex: 5Mb/part)
2:/ Let write new sdk using new httprequest then you can do it (write file stream to network stream)
Note: all lib (maybe) httprequest using memory stream and write data to network stream then the speed result is speed of DISK to RAM (file stream to memory stream)
1:/多上传(例如:5Mb /部分)2:/让我们使用新的httprequest写新sdk然后就可以了(将文件流写入网络流)注意:所有lib(可能)httprequest使用内存流并写入数据到网络流然后速度结果是DISK到RAM的速度(文件流到内存流)