-
-
Notifications
You must be signed in to change notification settings - Fork 35
Closed
Description
In Google Workspace organization where external sharing is disabled, uploading image files fails with the following error.
Error: failed to apply page: failed to upload image: failed to set permission for image: google api: Error 403: The user does not have sufficient permissions for this file., insufficientFilePermissions
The current process attempts to grant reader access to anyone.
Lines 216 to 235 in d4cdbb7
| uploaded, err := d.driveSrv.Files.Create(df).Media(bytes.NewBuffer(image.Bytes())).SupportsAllDrives(true).Do() | |
| if err != nil { | |
| image.SetUploadResult("", fmt.Errorf("failed to upload image: %w", err)) | |
| return nil | |
| } | |
| // Set permission | |
| if _, err := d.driveSrv.Permissions.Create(uploaded.Id, &drive.Permission{ | |
| Type: "anyone", | |
| Role: "reader", | |
| }).SupportsAllDrives(true).Do(); err != nil { | |
| // Clean up uploaded file on permission error | |
| if deleteErr := d.deleteOrTrashFile(ctx, uploaded.Id); deleteErr != nil { | |
| d.logger.Error("failed to delete uploaded file after permission error", | |
| slog.String("id", uploaded.Id), | |
| slog.Any("error", deleteErr)) | |
| } | |
| image.SetUploadResult("", fmt.Errorf("failed to set permission for image: %w", err)) | |
| return nil | |
| } |
It would be great if the upload process could handle restricted environments.
Related Reference:
Songmu and yamadashy
Metadata
Metadata
Assignees
Labels
No labels