0

I have the possibility to upload file to google drive (it's a teamdrive) with the code below. But how to create with Permission when files are available for anyone with a link? I am planning to show them on a website, so they must be public.

func createFile(service *drive.Service, name string, mimeType string, content io.Reader, 
     parentId string) (*drive.File, error) {
     f := &drive.File{
        MimeType: mimeType,
        Name:     name,
        Parents:  []string{parentId},
        DriveId:  "0ADWLSv3z4zp1Uk9PVA",
    }
    file, err := service.Files.Create(f).SupportsAllDrives(true).IncludePermissionsForView("published").Media(content).Do()

    if err != nil {
        log.Println("Could not create file: " + err.Error())
        return nil, err
    }

    return file, nil
}
Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
Svitlana
  • 2,324
  • 4
  • 22
  • 31
  • Have you tried changing the permission type after creating the file? [Permissions](https://developers.google.com/drive/api/v3/reference/permissions) – Kessy Feb 04 '21 at 16:02
  • Thx, Kessy. I do not know how to do it.... Can you give me some hints? – Svitlana Feb 04 '21 at 18:17
  • Have you checked how to do it? This post could help https://stackoverflow.com/questions/63935583/create-update-google-drive-permission-in-go-created-spreadsheet-using-api-but – Kessy Feb 11 '21 at 11:11

0 Answers0