使用Python EVE的RETURN_MEDIA_AS_URL时,如何在响应中找到关联资源的媒体URL

时间:2021-06-16 21:08:40

I've enabled RETURN_MEDIA_AS_URL within my settings.py. I have a schema that looks like this:

我在settings.py中启用了RETURN_MEDIA_AS_URL。我有一个如下所示的架构:

schema = {
    'type': 'dict',
    'schema': {
        'action': {
            'type': 'string',
            'default': 'Favorite'
        },
        'description': {
            'type': 'string',
            'default': 'I really liked this.'
        },
        'hyperlink': {
            'type': 'string',
            'default': 'http://placehold.it/300x300'
        },
        'pic': {
            'type': 'media'
        }
    }
}

After generating a resource, the response items payload looks like this:

生成资源后,响应项有效负载如下所示:

{
  "_updated": "2015-05-06T17:30:32Z",
  "description": "I really liked this.",
  "hyperlink": "http://placehold.it/300x300",
  "pic": {
        "upload_date": "2015-05-06T17:30:32Z",
        "length": 119861,
        "content_type": "image/png",
        "file": null,
        "name": "shoebot.png"
   },
   "_links": {
       "self": {
            "href": "notification/554a4fb8803bd747eb725d4a",
            "title": "Notification"
       }
   },
   ...
}

I have an API Prefix that looks like this: /api/v1/ I can't seem to figure out what GET url will respond back with my shoebot.png image from Eve.

我有一个API前缀,看起来像这样:/ api / v1 /我似乎无法弄清楚GET url会用Eve的shoebot.png图像回复什么。

Thanks for any advice to nudge me in the right direction :-)

感谢任何建议,以正确的方向推动我:-)

1 个解决方案

#1


Returning media as URL is currently on the development branch, targeted for v0.6 release. So unless you are running from the development branch, this feature is not yet available to you. You can of course pull it down and experiment with it freely if so you wish.

返回媒体作为URL当前在开发分支上,针对v0.6版本。因此,除非您从开发分支运行,否则此功能尚不可用。你当然可以把它拉下来,如果你愿意,可以*地试验它。

Hope this helps.

希望这可以帮助。

#1


Returning media as URL is currently on the development branch, targeted for v0.6 release. So unless you are running from the development branch, this feature is not yet available to you. You can of course pull it down and experiment with it freely if so you wish.

返回媒体作为URL当前在开发分支上,针对v0.6版本。因此,除非您从开发分支运行,否则此功能尚不可用。你当然可以把它拉下来,如果你愿意,可以*地试验它。

Hope this helps.

希望这可以帮助。