2025 年 4 月 1 日,我们移除了 Library API 中的部分镜重。
点击此处了解详情。
管理媒体内容
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
除了在上传媒体内容后访问和检索这些内容之外,您还可以更改其说明。
必需的授权范围
更改应用创建内容的说明需要 photoslibrary.edit.appcreateddata
范围。如需详细了解范围,请参阅授权范围。
如需更改媒体内容的说明,请使用媒体内容的标识符发出 media items update
call
,并在请求中添加新的说明。
如需更改媒体项的说明,您的应用必须已上传媒体项,并且当前经过身份验证的用户必须是所有者。说明不得超过 1,000 个字符。
REST
以下是用于更新媒体内容描述的 PATCH 请求标头:
PATCH https://photoslibrary.googleapis.com/v1/mediaItems/media-item-id?updateMask=description
此请求通过添加字段掩码(由网址中的 updateMask
参数表示)来确定要更新的媒体资源。
在请求正文中添加新说明:
{
"description": "new-media-item-description"
}
如果成功,响应将返回更新后的媒体内容:
{
"id": "media-item-id",
"description": "new-media-item-description",
"productUrl": "media-item-product-url",
"baseUrl": "media-items-in-album",
"mimeType": "mime-type-of-media",
"mediaMetadata": {
...
},
"contributorInfo": {
...
},
"fileName": "item-filename"
}
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-29。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["没有我需要的信息","missingTheInformationINeed","thumb-down"],["太复杂/步骤太多","tooComplicatedTooManySteps","thumb-down"],["内容需要更新","outOfDate","thumb-down"],["翻译问题","translationIssue","thumb-down"],["示例/代码问题","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-08-29。"],[[["\u003cp\u003eAfter uploading media items to Google Photos, you can change their descriptions using the Google Photos API.\u003c/p\u003e\n"],["\u003cp\u003eModifying descriptions of app-created content requires the \u003ccode\u003ephotoslibrary.edit.appcreateddata\u003c/code\u003e scope and ownership by the authenticated user.\u003c/p\u003e\n"],["\u003cp\u003eTo update a description, use the \u003ccode\u003emediaItems/patch\u003c/code\u003e endpoint with the item's ID and a request body containing the new description.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eupdateMask\u003c/code\u003e parameter in the request URL specifies that only the description is being modified.\u003c/p\u003e\n"],["\u003cp\u003eThe response to a successful update request will return the complete updated media item object.\u003c/p\u003e\n"]]],["To modify a media item's description, use a `media items update call` with a PATCH request, specifying the item's ID and the `updateMask` parameter. Include the new description in the request body, ensuring it's under 1,000 characters. This requires the `photoslibrary.edit.appcreateddata` scope, with the app having uploaded the media, and the authenticated user must be the owner. A successful request returns the updated media item details, including the new description.\n"],null,[]]