0

I have successfully uploaded a local file off my computer to my Google Drive as a PDF. However, when the file was uploaded, it is labeled as Untitled and not placed in any specific folder.

$GUploadBody= @" --BOUNDARY Content-Type: application/pdf; charset=UTF-8 { "title": "$title", "parents": [{ "id":"$parentfolder" }], "mimeType": "$inputmime", "description": "$description" } --BOUNDARY Content-Type: text/plain $togoogle --BOUNDARY-- "@ 

How do I make it so that the file uploaded is labeled with the file name, and how can I specify a folder in my Google Drive for that file to go to?

Here is the Invoke-WebRequest cmdlet I used:

Invoke-WebRequest -uri $GUploadURI -Method Post -body $GUploadBody -Headers $Guploadheaders -ContentType "application/pdf; charset=UTF-8" -UseBasicParsing 

I have found the syntax for other languages like Java, but Powershell must be used for automation purposes.

1
  • Try checking this github code, they have sample code for uploading to a specific folder for PowerShell and Drive API. Commented Aug 1, 2018 at 6:58

1 Answer 1

1

I've never used powershell but in Google Drive v3 'title' field has changed to 'name' and 'parents' is just an array of folderIds (["folderId1", "folderId2"]).

In that case, I believe it should return an error but you could try it.

Sign up to request clarification or add additional context in comments.

1 Comment

I tried that, but the content in the PDF file just reads exactly what I type in there. I think it might be a problem with the POST parameter.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.