MCPcopy Create free account
hub / github.com/openclaw/gogcli / runFile

Method runFile

internal/cmd/docs_insert_image.go:249–275  ·  view source on GitHub ↗
(ctx context.Context, docsSvc *docs.Service, driveSvc *drive.Service, docID, localPath, name, mimeType string, target docsImageTarget)

Source from the content-addressed store, hash-verified

247}
248
249func (c *DocsInsertImageCmd) runFile(ctx context.Context, docsSvc *docs.Service, driveSvc *drive.Service, docID, localPath, name, mimeType string, target docsImageTarget) (result docsInsertImageResult, err error) {
250 uploaded, err := uploadDocsInlineImage(ctx, driveSvc, localPath, name, mimeType, strings.TrimSpace(c.Parent))
251 if err != nil {
252 return result, err
253 }
254 result.uploadedFileID = uploaded.Id
255 result.uploadedFileName = uploaded.Name
256
257 perm, err := shareDocsImagePublicly(ctx, driveSvc, uploaded.Id)
258 if err != nil {
259 if strings.EqualFold(c.OnRestricted, "link") && isDrivePublicSharingRestricted(err) {
260 return c.insertRestrictedImageFallback(ctx, docsSvc, docID, uploaded, target, result)
261 }
262 return result, fmt.Errorf("share uploaded image publicly: %w", err)
263 }
264 result.permissionID = perm.Id
265
266 defer func() {
267 if perm.Id == "" {
268 return
269 }
270 result.revoked, err = finishDocsImagePublicShare(ctx, driveSvc, uploaded.Id, perm.Id, err)
271 }()
272
273 imageURL := driveImageDownloadURL(uploaded.Id)
274 return c.insertImageURL(ctx, docsSvc, docID, imageURL, target, result)
275}
276
277func (c *DocsInsertImageCmd) insertImageURL(ctx context.Context, docsSvc *docs.Service, docID, imageURL string, target docsImageTarget, result docsInsertImageResult) (docsInsertImageResult, error) {
278 reqs, index, tabID, err := c.buildInsertRequests(ctx, docsSvc, docID, target, imageURL)

Callers 1

RunMethod · 0.95

Calls 8

insertImageURLMethod · 0.95
uploadDocsInlineImageFunction · 0.85
shareDocsImagePubliclyFunction · 0.85
driveImageDownloadURLFunction · 0.85
ErrorfMethod · 0.80

Tested by

no test coverage detected