Create Images

An image can be created by using the createSkylarkImage mutation. There are three ways to provide the image file.

Upload an Image from a local drive

Please click on the recipe for further information:

Sample Request:

mutation createSkyarkImage {
  createSkyarkImage(
    skylark_image: {
      slug: "season-1-header", 
      title: "Season 1 header", 
      type: HEADER, 
      content_type: "image/png"
    }
  ) {
    upload_url
    uid
    title
  }
}

Expected Result:

{
  "data": {
    "createSkylarkImage": {
      "upload_url": "https://object-registry-bucket-sl-f-sl-2238-eu-west-1-storage.s3.amazonaws.com/media/images/appsync-console/01GKSF3WN2YXZN03AEWTNR2X6V/01GKSF3Y3YW7SXWY7Q5AAR04DP.png?AWSAccessKeyId=ASIAQP5PT3NI55PNKCA3&Signature=D1oLNGFjyRh04BudCkqUUefRL%2Fc%3D&content-type=image%2Fpng&x-amz-meta-account_id=appsync-console&x-amz-meta-uid=01GKSF3WN2YXZN03AEWTNR2X6V&x-amz-security-token=IQoJb3JpZ2luX2VjECMaCWV1LXdlc3QtMSJIMEYCIQD0sTb0uSVDRvbAgVmOO3PharQjaZZHI0SkCBLeCIyuwAIhAIs4vxOx3o2WNWFPILtWxbmhsAJITyOMx8WuaL9f4B83KrEDCEsQARoMMDM0MTkxMTcwMzg1IgxdF8E%2BCoOBmE0ljT8qjgO%2FajeTlvGzjPomXMBvYM1DXP9b6UoR1iS5fXovNOENisHp1OpiXvQnmCeI9zDe5TCOlmxwP%2BGvWCITkyTmC07%2B7i4IIkGwgRXcgAEGVABPy0IbUu4ENQvkj65dfjrnN3Jl3kWY49sDqS7IAPBXFda5t%2FJ2o%2BGmOzTdRibDFgvxyCCHgu%2FkroG0PAbuSEDpvuJpuk9YIjZiVRKVdOli01xwK9UJccvH3yCiEswvnbV7OD9Ssbf4IAm4kwsmdNveactZ5gHQWI6E17UGlrTNUevruNRHIVdEb7llskQCd7tCBXdRkYsD7AzHCo2BZh7wo1OxFsqcG5MIR8dRWvbwmSI2U5TsS4K6g%2BLQOrPSNC6ABb7ldDfU7tIs7bSKA3wBc4VnTB%2FvWg0jt9R%2BmuSAO8LPB6It0qnNvWnwMQ40nNRpmquKVyZ1TqiPjm%2BNUUD4pWClL3AuRhawzmNwTb49iQZs4ZWFGQkmN9nuCDz7Z%2Fm0xy4Z4L3tUG9%2F%2FMQjOUUyGUiEzwkbwXcMeqP%2F4XEYZjD10sicBjqcASjNb97C6uvLbg0GuIK%2BTV2lHLzLAmY6dhDve283yTERa245DEIxEMBLTTTv2vbiFtsJeVpVKVwRVGlOWpWp1tkONWLS4qFt5DyU3z0fwVzWQEfB42I2zGZT4R%2Bhn2ftL0kNa%2F%2BdbYMx5GLfJNIzAqW%2BqME4FdklndkT6Hv5GbebGus4gkYG2jdaFZ4Uip2aDLbM%2F5LOynSo4TYzRg%3D%3D&Expires=1670526855",
      "uid": "01GKSF3WN2YXZN03AEWTNR2X6V",
      "title": "Season 1 header"
    }
  }
}

Upload to Skylark like this:

import requests


upload_url = '<upload_url>' #check expected result above
file_path = '/<local path>/sample_image.png'
with open(file_path, 'rb') as f:
    data = f.read()
header = {'Content-Type': 'image/png'}
http_response = requests.put(upload_url, data=data, headers=header)

Upload an Image from an external URL

Please click on the recipe for further information:

Sample Request:

mutation createSkyarkImage {
  createSkylarkImage(
    skylark_image: {
      slug: "season-1-header", 
      title: "Season 1 header", 
      type: HEADER, 
      content_type: "image/jpg", 
      download_from_url: "https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/images/ForBiggerEscapes.jpg"
    }
  ) {
    uid
    title
  }
}

Expected Result:

{
  "data": {
    "createSkylarkImage": {
      "uid": "01GTYJE9ZB5H9HJS6H4QC16JRA",
      "title": "Season 1 header"
    }
  }
}

Create an Image using an externally hosted file

Please click on the recipe for further information:

Sample Request:

mutation createSkyarkImage {
  createSkyarkImage(
    skylark_image: {
      slug: "season-1-header", 
      title: "Season 1 header", 
      type: HEADER, 
      content_type: "image/jpg", 
      external_url: "https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/images/ForBiggerEscapes.jpg"
    }
  ) {
    uid
    title
  }
}

Expected Result:

{
  "data": {
    "createSkylarkImage": {
      "uid": "01GTYJGQZ8QVC5FTF8JPRG475Z",
      "title": "Season 1 header"
    }
  }
}