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

Method replaceImageURL

internal/cmd/docs_replace_image.go:200–228  ·  view source on GitHub ↗
(
	ctx context.Context,
	svc *docs.Service,
	docID string,
	target docsReplaceImageTarget,
	imageURL string,
)

Source from the content-addressed store, hash-verified

198}
199
200func (c *DocsReplaceImageCmd) replaceImageURL(
201 ctx context.Context,
202 svc *docs.Service,
203 docID string,
204 target docsReplaceImageTarget,
205 imageURL string,
206) (docsReplaceImageResult, error) {
207 request := &docs.BatchUpdateDocumentRequest{
208 Requests: []*docs.Request{{ReplaceImage: &docs.ReplaceImageRequest{
209 ImageObjectId: target.image.ObjectID,
210 Uri: imageURL,
211 ImageReplaceMethod: docsImageReplaceMethodCenterCrop,
212 TabId: target.tabID,
213 }}},
214 WriteControl: docsRequiredRevisionWriteControl(target.revisionID),
215 }
216 if _, err := svc.Documents.BatchUpdate(docID, request).Context(ctx).Do(); err != nil {
217 if isDocsNotFound(err) {
218 return docsReplaceImageResult{}, fmt.Errorf("doc not found or not a Google Doc (id=%s)", docID)
219 }
220 return docsReplaceImageResult{}, fmt.Errorf("replace image: %w", err)
221 }
222 return docsReplaceImageResult{
223 documentID: docID,
224 image: target.image,
225 tabID: target.tabID,
226 sourceURL: imageURL,
227 }, nil
228}
229
230func writeDocsReplaceImageResult(ctx context.Context, result docsReplaceImageResult) error {
231 if outfmt.IsJSON(ctx) {

Callers 2

RunMethod · 0.95
replaceImageFileMethod · 0.95

Calls 5

isDocsNotFoundFunction · 0.85
ErrorfMethod · 0.80
DoMethod · 0.65
BatchUpdateMethod · 0.65

Tested by

no test coverage detected