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
}
4

0 回答 0