Object handler¶
Handler for work with a object
- class luna_image_store.app.handlers.object_handler.ObjectHandler(request)[source]¶
Handler for work with object(text/json/zip/pdf).
- async delete(bucketName, objectId)[source]¶
Delete object from bucket. See spec_delete_object.
- Parameters
bucketName (
str
) – bucket nameobjectId (
str
) – object id
- Return type
HTTPResponse
- Returns
response with status code 204
- async get(bucketName, objectId)[source]¶
Get object from bucket. See spec_get_object.
- Parameters
bucketName (
str
) – bucket nameobjectId (
str
) – object id
- Return type
HTTPResponse
- Returns
response with object in body, if status code 200, Error.BadContentType with status code 400, if bad content type, Error.NotAcceptable with status code 406, if content-type not acceptable.
- async head(bucketName, objectId)[source]¶
Check object exists in bucket. See spec_head_object.
- Parameters
bucketName (
str
) – bucket nameobjectId (
str
) – object id
- Return type
HTTPResponse
- Returns
response with status code 200, if object exist, Error.BadContentType with status code 400, if bad content type, Error.NotAcceptable with status code 406, if content-type not acceptable.
- class luna_image_store.app.handlers.object_handler.StreamObjectHandler(request)[source]¶
Handler for work with object with streaming.
Separate class used due to strange behavior of sanic/cow - after decorating single method other methods becomes “stream” too and user has to consume stream instead of getting data from request.body.
Resource: “{api_version}/buckets/{bucketName}/objects/{objectId}”
- async put(bucketName, objectId)[source]¶
Put object to bucket. See spec_put_object.
- Parameters
bucketName (
str
) – bucket nameobjectId (
str
) – object id
- Return type
HTTPResponse
- Returns
response with object id and location, if status code 200, Error.UnsupportedMediaType with status code 415, if unsupported media type.