I have attempted to send the name in the object "formData.append" within the code structure, but unfortunately, I have not achieved success.
The documentation states that the name should be sent in the body.
Useful Documentation Links: https://developers.google.com/drive/api/v3/reference/files/create - https://developers.google.com/drive/api/v3/manage-uploads#http_1
Received Response:
{ "kind": "drive#file", "id": "1uz_NN-IyoiPzaheAiKIJu6qlB7ZfxIX2", "name": "Untitled", "mimeType": "application/x-www-form-urlencoded" }
Name: "Untitled"
- Any assistance would be greatly appreciated
Upload.prototype.doUpload = function () {
var that = this;
var formData = new FormData();
formData.append("file", this.file);
formData.append("upload_file", true);
formData.append("name", "test_file");
$.ajax({
type: "POST",
beforeSend: function(request) {
request.setRequestHeader("Authorization", "Bearer" + " " + localStorage.getItem("accessToken"));
},
url: "https://www.googleapis.com/upload/drive/v3/files",
data:{
uploadType:"multipart"
},
success: function (data) {
console.log(data);
},
error: function (error) {
console.log(error);
},
async: true,
data: formData,
cache: false,
processData: false,
timeout: 60000
});
};