创建分段上传目标URL-stagedUploadsCreate mutation
为每个输入创建分段的上传目标URL,这是上传过程的第一步。返回的带有URL的上载目标可用作上载文件的端点。
在本页面
互动范例
这是一个示例变异查询。
mutation stagedUploadsCreate($input: [StagedUploadInput!]!) { stagedUploadsCreate(input: $input) {} }
<font style="color:#1F61A0;">stagedTargets</font> <font style="color:#555555;">{</font><font style="color:#1F61A0;">resourceUrl</font><font style="color:#1F61A0;">url</font><font style="color:#555555;">}</font><font style="color:#1F61A0;">userErrors</font> <font style="color:#555555;">{</font><font style="color:#1F61A0;">field</font><font style="color:#1F61A0;">message</font><font style="color:#555555;">}</font>
变量:
{ “input”: [] }
<font style="color:#555555;">{</font><font style="color:#8B2BB9;">"resource"</font><font style="color:#555555;">:</font> <font style="color:#D64292;">"placeholder"</font><font style="color:#555555;">,</font><font style="color:#8B2BB9;">"filename"</font><font style="color:#555555;">:</font> <font style="color:#D64292;">"placeholder"</font><font style="color:#555555;">,</font><font style="color:#8B2BB9;">"mimeType"</font><font style="color:#555555;">:</font> <font style="color:#D64292;">"placeholder"</font><font style="color:#555555;">}</font>
参数
| 参数 | 描述 |
|---|---|
input( [[StagedUploadInput!]!](https://shopify.dev/docs/admin-api/graphql/reference/common-objects/stageduploadinput))必需的 |
突变的输入包括生成分段上传目标所需的信息。 |
StagedUploadInput字段
- fileSize(
[UnsignedInt64](https://shopify.dev/docs/admin-api/graphql/reference/scalar#unsignedint64-2021-01))
要上传的文件大小,以字节为单位。这是VIDEO和MODEL_3D资源所必需的。 - filename(
[String!](https://shopify.dev/docs/admin-api/graphql/reference/scalar#string-2021-01)) 必需的
媒体文件名。 - httpMethod(
[StagedUploadHttpMethodType](https://shopify.dev/docs/admin-api/graphql/reference/common-objects/stageduploadhttpmethodtype))
分段上传将使用的HTTP方法。 - mimeType(
[String!](https://shopify.dev/docs/admin-api/graphql/reference/scalar#string-2021-01)) 必需的
媒体MIME类型。 - resource(
[StagedUploadTargetGenerateUploadResource!](https://shopify.dev/docs/admin-api/graphql/reference/common-objects/stageduploadtargetgenerateuploadresource)) 必需的
媒体资源。
返回字段
- stagedTargets(
[[StagedMediaUploadTarget!]](https://shopify.dev/docs/admin-api/graphql/reference/products-and-collections/stagedmediauploadtarget))
生成的暂存上传目标。 - userErrors(
[[UserError!]!](https://shopify.dev/docs/admin-api/graphql/reference/usererror))
执行mutation时发生的错误列表。
