How to get an uploaded file URL from the shopify Admin API

Viewed 570

I am currently saving some images in shopify via File API:

mutation fileCreate($files: [FileCreateInput!]!) {
                fileCreate(files: $files) {
                files {
                    alt
                }
                userErrors {
                    field
                    message
                }
                }
            }',
        [
            'files' => [
                'alt' => $alt_text,
                'contentType' => 'IMAGE',
                'originalSource' => $from_url,
            ]
        ]

It works, but unfortunately I am not able to get the url in return. It returns null as if it's still processing. Is there any way to do it? I am saving the image name locally, but I wouldn't consider querying the api again for each single one a valid solution (too many files, huge overhead)

Thanks in advance

1 Answers

I have tried above code on my project and it works but i didn't get any return url but get the following response object.

[
   {
     alt: 'pexels-albina-white-11780519.jpg',
     createdAt: '2022-07-12T06:07:59Z',
     fileErrors: [],
     fileStatus: 'UPLOADED',
     __typename: 'GenericFile',
     preview: { image: null }
   }
 ]

Shopify didn't provide the reading files from admin file not from any api for public apps.If any idea to read file from the api admin file then Please answer for this Query.

Related