def _start_upload(
self,
digest,
mount=None
):
"""POST to begin the upload process with optional cross-repo mount param."""
if not mount:
# Do a normal POST to initiate an upload if mount is missing.
url = '{base_url}/blobs/uploads/'.format(base_url=self._base_url())
accepted_codes = [httplib.ACCEPTED]
else:
# If we have a mount parameter, try to mount the blob from another repo.
mount_from = '&'.join(
['from=' + urllib.quote(repo.repository, '') for repo in self._mount])
url = '{base_url}/blobs/uploads/?mount={digest}&{mount_from}'.format(
base_url=self._base_url(),
digest=digest,
mount_from=mount_from)
accepted_codes = [httplib.CREATED, httplib.ACCEPTED]
resp, unused_content = self._transport.Request(
url, method='POST', body=None,
accepted_codes=accepted_codes)
# pytype: disable=attribute-error
return resp.status == httplib.CREATED, resp.get('location')
# pytype: enable=attribute-error
评论列表
文章目录