Media Upload Mutation Problems

Highlighted
Shopify Expert
4182 29 402

I make a mutation call:

 

mutation generateStagedUploads($input: [StagedUploadInput!]!) {
  stagedUploadsCreate(input: $input) {
    stagedTargets {
      url
      resourceUrl
      parameters {
        name
        value
      }
    }
    userErrors { field, message }
  }
}

With good data:

{
  "input" : [
    {
      "filename": "srrs04ypl.jpg",
      "mimeType": "image/jpeg",
      "resource": "IMAGE"
    }  
  ]
}

And I get back some data to use:

{
  "data": {
    "stagedUploadsCreate": {
      "stagedTargets": [
        {
          "url": "https:\/\/shopify.s3.amazonaws.com\/tmp\/33597522059\/products\/09d10e72-457f-43b8-a2fa-c895b55031a2\/srrs04ypl.jpg?x-amz-acl=private&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAJYM555KVYEWGJDKQ%2F20200320%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20200320T031320Z&X-Amz-Expires=900&X-Amz-SignedHeaders=host&X-Amz-Signature=a119d6fc56a38c2b6bc6c59bc3f9ae4292813aa5c5446c7162d0881932de47ec",
          "resourceUrl": "https:\/\/shopify.s3.amazonaws.com\/tmp\/33597522059\/products\/09d10e72-457f-43b8-a2fa-c895b55031a2\/srrs04ypl.jpg",
          "parameters": [
            {
              "name": "content_type",
              "value": "image\/jpeg"
            },
            {
              "name": "acl",
              "value": "private"
            }
          ]
        }
      ],
      "userErrors": []
    }
  },
  "extensions": {
    "cost": {
      "requestedQueryCost": 11,
      "actualQueryCost": 11,
      "throttleStatus": {
        "maximumAvailable": 1000.0,
        "currentlyAvailable": 989,
        "restoreRate": 50.0
      }
    }
  }
}

So at this point, I have a JPG on my hard drive that I need to upload to the URL provided. Once it is there, I can then reference it and use it to assign it to a product. Except when I try and upload the image using curl, I get back a rejection error from Amazon... so what is the point of this?

 

curl -v  \
      -F "x-amz-acl=private" \
      -F "X-Amz-Algorithm=AWS4-HMAC-SHA256" \
      -F "X-Amz-Credential=AKIAJYM555KVYEWGJDKQ%2F20200320%2Fus-east-1%2Fs3%2Faws4_request" \
      -F "X-Amz-Date=20200320T013706Z" \
      -F "X-Amz-Expires=900" \
      -F "X-Amz-SignedHeaders=host" \
      -F "X-Amz-Signature=a119d6fc56a38c2b6bc6c59bc3f9ae4292813aa5c5446c7162d0881932de47ec" \
      -F "file=@/Users//Documents/Workspace/Apps/tmp/images/sku/srrs04ypl.jpg" \
      "https://shopify.s3.amazonaws.com/tmp/33597522059/products/52dc6d76-3043-47dd-ba89-395ecb507495/srrs04ypl.jpg"

Results in Amazon saying to me:

 

<Error><Code>MethodNotAllowed</Code><Message>The specified method is not allowed against this resource.</Message><Method>POST</Method><ResourceType>OBJECT</ResourceType><RequestId>D23712C006757BCD</RequestId><HostId>Q7aNeD3Ddv3Tc0RO/QjmNaa0DygMXHbThrwbEvDuJNVOKeR/fkgMV6U5aEpG1Oj9vAJuh+f5Hag=</HostId></Error>

 

 

 

 

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
0 Likes
Highlighted
Shopify Expert
4182 29 402

ahhh never mind... I see images get uploaded totally different than videos... oops

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
0 Likes
Highlighted
Shopify Partner
18 0 1

How did you upload the images?  I tried many times not working,   I can't post .  if I do put. there is no response ..  response me 1

0 Likes
Highlighted
Shopify Expert
4182 29 402

Shopify has a tutorial. I followed it, except I screwed up the curl code for the media. If you follow their examples, it all works perfect.

 

The only thing I failed so far to do, was convert from using curl to Ruby for my transfer to Amazon, with the pre-signed bucket code. I will eventually revisit that, but for now, I was able to quickly upload many hundreds of images just using Shopify code suggestions.

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
0 Likes