A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
Hi all,
So I managed to crack how to upload images to Shopify using this: https://shopify.dev/apps/online-store/media/products
I am now trying to upload videos, using pretty much the same workflow, and its going grand until I reach the part where I am to upload my file to the Amazon/Google bucket to then get a URL to post to createProductMedia().
I receive:
stdClass Object ( [Code] => EntityTooSmall [Message] => Your proposed upload is smaller than the minimum object size specified in your Policy Document. [Details] => Content-length smaller than lower bound on range )
as an error message.
I have tried with different sized videos, over 5mb and under 5mb, and in StagedUploadsCreate adjusted the "fileSize" parameter to account for which video I am trying to upload.
Has anyone encountered this problem before?
I will gladly post more code if this post receives any traction, but for now am just wondering if anyone has encountered this error before, in the meantime I will keep trying 😉
Cheers,
Matthias
Solved! Go to the solution
This is an accepted solution.
Hello again @Matthias7 👋
Below is a sample curl request that may be helpful to upload the video. When the upload is successful, there generally isn't a response body other than the 204 code. Keep in mind, we'll want to arrange the file to be last in the form data.
curl -L -X POST {StagedMediaUploadTarget.url GOES HERE} \
-F 'GoogleAccessId={StagedMediaUploadTarget.parameters CONTAINS THIS}' \
-F 'key={StagedMediaUploadTarget.parameters CONTAINS THIS}' \
-F 'policy={StagedMediaUploadTarget.parameters CONTAINS THIS}' \
-F 'signature={StagedMediaUploadTarget.parameters CONTAINS THIS}' \
-F 'file=@{RELATIVE PATH DIR TO VIDEO FILE}'
To streamline the process, you can store the response from `stagedUploadsCreate` mutation then build the upload request by iterating over the `parameters` list. The `url` field will be needed in the upload step, and the `resourceUrl` will be consumed to create the video resource object.
Hope that helps!
Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
Ok so I found what causes this error based on another Forum post:
https://community.shopify.com/c/shopify-discussions/cannot-upload-video-object-to-the-shopify-via-ap...
there it states that an incorrect parameter is being sent as the file e.g. a string being sent rather than the file itself.
Since I am using PHP and CURL I have tried the following to remedy this:
1. To use "new \CURLFile()" (like I do when successfully uploading Images) - I get no response from API, error or otherwise
2. To use "file_get_contents()" - I get no response from API, error or otherwise
Open to suggestions 😄
Cheers,
Matthias
This is an accepted solution.
Hello again @Matthias7 👋
Below is a sample curl request that may be helpful to upload the video. When the upload is successful, there generally isn't a response body other than the 204 code. Keep in mind, we'll want to arrange the file to be last in the form data.
curl -L -X POST {StagedMediaUploadTarget.url GOES HERE} \
-F 'GoogleAccessId={StagedMediaUploadTarget.parameters CONTAINS THIS}' \
-F 'key={StagedMediaUploadTarget.parameters CONTAINS THIS}' \
-F 'policy={StagedMediaUploadTarget.parameters CONTAINS THIS}' \
-F 'signature={StagedMediaUploadTarget.parameters CONTAINS THIS}' \
-F 'file=@{RELATIVE PATH DIR TO VIDEO FILE}'
To streamline the process, you can store the response from `stagedUploadsCreate` mutation then build the upload request by iterating over the `parameters` list. The `url` field will be needed in the upload step, and the `resourceUrl` will be consumed to create the video resource object.
Hope that helps!
Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
A true hero!
Thank you for your time.
I was tunnel visioning and following too closely the `BulkOperation` procedure.
I was expecting to:
1. receive a reply from the CURL request you posted above
2. then use that reply in the `originalSource` field
Using the `resourceUrl` in `productCreateMedia` from `stagedUploadsCreate` uploaded the file like a charm. 🙂
Cheers,
Matthias
We followed this command and the result was the same. What is the specific problem?
The command we submitted is as follows:
curl -v \
-F "GoogleAccessId=video-production@video-production-225115.iam.gserviceaccount.com" \
-F "key=c/o/v/1ac203da076a45a58a03ac8a1093e1e5.mp4" \
-F "policy=eyJjb25kaXRpb25zIjpbWyJlcSIsIiRidWNrZXQiLCJzaG9waWZ5LXZpZGVvLXByb2R1Y3Rpb24tY29yZS1vcmlnaW5hbHMiXSxbImVxIiwiJGtleSIsImMvby92LzFhYzIwM2RhMDc2YTQ1YTU4YTAzYWM4YTEwOTNlMWU1Lm1wNCJdLFsiY29udGVudC1sZW5ndGgtcmFuZ2UiLDk3ODMyNiw5NzgzMjZdXSwiZXhwaXJhdGlvbiI6IjIwMjQtMDYtMjVUMDc6MTQ6MjNaIn0=" \
-F "signature=BfxwvYorVvXIrLKMk06kQmxhkiKGfB633ssLMN1EUziVGnK47PvoYc8C9pJdypo1kQ+bq0zxyZWJJ9EAjAnSRSikR1Z6xb9ki59sSucwq07pCY/cM+2R/uOjST5gfp8G+0d90Tswy/zMIH6OpEixQHeYkkIrRRWPG8oYXTCfMDQegVdAZDlRJLwbRN8X4oEBw0Mn18cJ/zRDi6HSYl7KRtuXDAq+mqaPrLsUGXRG45YTBZSMP5bUJvRGUOycQQl5D8jKAxUzK+UC5sZ/7JuGT1Bolkb+fu6xy69cF5iAJoOCG650QX5Jg959rAtmzvQUjSE9CJcLiZWVu393pstNgw==" \
-F "file=****.mp4" \
"https://shopify-video-production-core-originals.storage.googleapis.com"
response:
your proposed upload is smaller than the minimum object size specified in your Policy Document.