What's your biggest current challenge? Have your say in Community Polls along the right column.
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Unable to use mutation stagedUploadsCreate together with resourcetype VIDEO on Google Cloud

Solved

Unable to use mutation stagedUploadsCreate together with resourcetype VIDEO on Google Cloud

friendoftheroot
Shopify Partner
50 5 8

I have a problem with just the mutation stagedUploadsCreate($input: [StagedUploadInput!]!), which is the first step of uploading. It should provide a url and resourceUrl.

I have uploaded 10.000 images and 1000 videos via graphql mutations with the same code before.
Also tried several approaches and debug outputs and it all points to the following issue:

From time to time Shopify changes from AWS to Google Cloud and when that happens somehow I cannot get the stagedUploadsCreate to provide me the required data.


With Google Cloud and only when I try a resourcetype VIDEO, the parameters come back empty.

Works with resourcetype: FILE

 Request ID: bc8f992c-85f3-4cd6-9847-b719a185f5c6-1720650841

Does not work with resourcetype: VIDEO

 Request ID: 5d5d3ebc-d4ca-40d2-acf9-a1e470841efd-1720651119


Code Snippet used both times:

 

$filename = "__test234.mp4"; // Assume this is the file you want to upload
$filenamepath = "/path/".$filename;
$mimeType = mime_content_type($filenamepath);
$resourcetype = "VIDEO";
$fileSize = filesize($filenamepath);

$graphql_query = <<<GRAPHQL
mutation stagedUploadsCreate(\$input: [StagedUploadInput!]!) {
  stagedUploadsCreate(input: \$input) {
    stagedTargets {
      url
      resourceUrl
      parameters {
        name
        value
      }
    }
  }
}
GRAPHQL;

$variables = [
    "input" => [
        [
            "filename" => (string) $filename,
            "mimeType" => $mimeType,
            "httpMethod" => "POST",
            "resource" => $resourcetype,
            "fileSize" => (string) $fileSize
        ]
    ]
];

$post_data = json_encode([
    'query' => $graphql_query,
    'variables' => $variables
]);

 


What I send is the same in both instances, except resource

 

(
[filename] => __test234
[mimeType] => video/mp4
[httpMethod] => POST
[resource] => VIDEO
[fileSize] => 4240733 
)

 


But I get it back empty:

 

Array
(
 [url] =>
    [resourceUrl] =>
    [parameters] => Array
)

 

 

Accepted Solution (1)
friendoftheroot
Shopify Partner
50 5 8

This is an accepted solution.

Shopify API error messages are not up to the task!
When manually uploading in backend I have now a usable error message that is the reason for the problem.

Error with files
Your plan allows you a maximum of 1000 videos and 3D models. Upgrade your plan to add more.

So this has nothing to do with Shopify now using Google Cloud for videos, but the number of allowed videos have been exceeded for this plan.

View solution in original post

Replies 2 (2)

friendoftheroot
Shopify Partner
50 5 8

Still need a hand here. 
Let me reiterate so it becomes clear.

My solution worked in AWS.
My solution works with FILE and IMAGE type.
But with VIDEO type I do not get an output.

Even when I use the official code and variables from here:
https://shopify.dev/docs/api/admin-graphql/2024-07/mutations/stageduploadscreate

These input variables:

{
  "input": [
    {
      "filename": "image1.png",
      "mimeType": "image/png",
      "httpMethod": "POST",
      "resource": "IMAGE"
    },
    {
      "filename": "video.mp4",
      "mimeType": "video/mp4",
      "fileSize": "1234",
      "resource": "VIDEO"
    },
    {
      "filename": "3d_model.glb",
      "mimeType": "model/gltf-binary",
      "resource": "MODEL_3D",
      "fileSize": "456"
    }
  ]
}


give me resourceUrls only for IMAGE and FILE.
Video comes back empty since shopify changed to Google Cloud.

There is not upload done at all at this stage.
This is just to retrieve the staging URL.

Permissions to write and read files is of course given to my app.

No error message. Eg. when I put a huge filesize for VIDEO I do get an error message.
What could be the reason?

friendoftheroot
Shopify Partner
50 5 8

This is an accepted solution.

Shopify API error messages are not up to the task!
When manually uploading in backend I have now a usable error message that is the reason for the problem.

Error with files
Your plan allows you a maximum of 1000 videos and 3D models. Upgrade your plan to add more.

So this has nothing to do with Shopify now using Google Cloud for videos, but the number of allowed videos have been exceeded for this plan.