将文件上传到云端硬盘并设置文件名称 [英] Upload file to Drive and set file name
本文介绍了将文件上传到云端硬盘并设置文件名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想将文件上传到Google云端硬盘并设置其名称,因为我知道我必须使用 uploadType = multipart
I want to upload a file to Google Drive and set its name as I understood I have to use uploadType=multipart
我在c ++下并使用cURL lib。
I am under c++ and using cURL lib.
我该如何继续?
How can I proceed?
推荐答案
您需要使用元数据和媒体部分进行多部分请求。使用 curl_formadd
并确保您的请求如下所示:
You need to make a multipart request with metadata and media parts. Use curl_formadd
and make sure your request looks like:
POST /upload/drive/v2/files?uploadType=multipart HTTP/1.1
Host: www.googleapis.com
Authorization: your_auth_token
Content-Type: multipart/related; boundary="boundary_tag"
--boundary_tag
Content-Type: application/json; charset=UTF-8
{
"title": "My title"
}
--boundary_tag
Content-Type: image/jpeg
data
--boundary_tag--
这篇关于将文件上传到云端硬盘并设置文件名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文