parent
94effb5aaa
commit
ee0eb80c8f
6 changed files with 14 additions and 10 deletions
|
@ -21,6 +21,7 @@ logger = logging.getLogger(__name__)
|
|||
BASE_BLOB_ROUTE = '/<namespace>/<repo_name>/blobs/<regex("{0}"):digest>'
|
||||
BLOB_DIGEST_ROUTE = BASE_BLOB_ROUTE.format(digest_tools.DIGEST_PATTERN)
|
||||
RANGE_HEADER_REGEX = re.compile(r'^bytes=([0-9]+)-([0-9]+)$')
|
||||
BLOB_CONTENT_TYPE = 'application/octet-stream'
|
||||
|
||||
|
||||
class _InvalidRangeHeader(Exception):
|
||||
|
@ -60,6 +61,7 @@ def check_blob_exists(namespace, repo_name, digest):
|
|||
response = make_response('')
|
||||
response.headers.extend(headers)
|
||||
response.headers['Content-Length'] = found.image_size
|
||||
response.headers['Content-Type'] = BLOB_CONTENT_TYPE
|
||||
return response
|
||||
|
||||
|
||||
|
@ -87,6 +89,7 @@ def download_blob(namespace, repo_name, digest):
|
|||
database.close_db_filter(None)
|
||||
|
||||
headers['Content-Length'] = found.image_size
|
||||
headers['Content-Type'] = BLOB_CONTENT_TYPE
|
||||
|
||||
return Response(storage.stream_read(found.locations, path), headers=headers)
|
||||
|
||||
|
@ -200,7 +203,8 @@ def _upload_chunk(namespace, repo_name, upload_uuid):
|
|||
try:
|
||||
length_written, new_metadata = storage.stream_upload_chunk({found.location.name}, upload_uuid,
|
||||
start_offset, length, input_fp,
|
||||
found.storage_metadata)
|
||||
found.storage_metadata,
|
||||
content_type=BLOB_CONTENT_TYPE)
|
||||
except InvalidChunkException:
|
||||
_range_not_satisfiable(found.byte_count)
|
||||
|
||||
|
|
Reference in a new issue