How to upload image from url using Image service REST API

Asked by Ksenia on 2015-10-08

I'm looking for a way to upload images from external URL using Image service API , but I can't find in API docs how to pass URL argument to create image method or to any other method.
Is API v2 support uploading images from URL and how?
And the same questions about API v1.


Question information

English Edit question
Glance Edit question
No assignee Edit question
Solved by:
Last query:
Last reply:

For v1 you can do:

 glance --os-image-api-version 1 image-create --copy-from ...

for v2 there is currently no universally recognised way to do this.

There is some design work going on around importing images using v2 at the moment, stay tuned.

Ksenia (ks-malysheva) said : #2

Thanks for the answer,
but I need a way to do this via REST Api from my frontend.

I make a POST request to glance endpoint:
POST /v1/images
with request payload:

Response received:
400 Bad Request
Invalid disk format 'None' for image.

But image is created, with id instead of name, in state queued (and it never changes to Active) and 0 bytes size.
What is correct way to upload image from url via Rest api?

wangxiyuan (wangxiyuan) said : #3

In v1, You should pass parameter in header, like : x-image-meta-disk_format, not in body.

Ksenia (ks-malysheva) said : #4

Hi all,
thanks for answers!

Looks like in REST Api v1 we can do following request:
POST v1/images

headers: {
  'x-glance-api-copy-from': '<image_url>',
  'x-image-meta-name': '<image_name>'

Request shouldn't contain body.

Gary Marchiny (gary-marchiny) said : #5

I've recently reported a 'bug' that is related to this topic: