Exemple #1
0
	def __getOperation(self, getData=True):
		startRange, endRange = self.__digestRange()
		result = Object.getObject( user = self.utakaReq.user,
			bucket=self.utakaReq.bucket, key=self.utakaReq.key,
			byteRangeStart = startRange, byteRangeEnd = endRange,
			ifModifiedSince=self.utakaReq.req.headers_in.get('if-modified-since'),
			ifNotModifiedSince=self.utakaReq.req.headers_in.get('if-unmodified-since'),
			ifMatch = self.utakaReq.req.headers_in.get('if-match'),
			ifNotMatch = self.utakaReq.req.headers_in.get('if-none-match'),
			ifRange = self.utakaReq.req.headers_in.get('if-range'),
			getMetadata = True, getData = getData)
		self.utakaReq.req.headers_out['ETag'] = result['eTag']
		self.utakaReq.req.headers_out['Content-Length'] = str(result['size'])
		self.utakaReq.req.content_type = result['content-type']
		self.utakaReq.req.headers_out['Last-Modified'] = result['lastModified']
		if 'content-encoding' in result:
			self.utakaReq.req.headers_out['Content-Encoding'] = result['content-encoding']
		if 'content-disposition' in result:
			self.utakaReq.req.headers_out['Content-Disposition'] = result['content-disposition']
		if 'content-range' in result:
			self.utakaReq.req.headers_out['Content-Range'] = result['content-range']
		if 'metadata' in result:
			for tag, val in result['metadata']:
				self.utakaReq.req.headers_out[self.utakaReq.customHeaderPrefix + tag] = val
		if getData:
			self.utakaReq.write(result['data'])
Exemple #2
0
	def __putOperation(self):
		cannedACL = self.utakaReq.customHeaderTable.get('acl', 'private')
		acp = {}
		acp['owner'] = {'userid': (self.utakaReq.user or str(1))}
		acl = [{'grantee':{'userid': (self.utakaReq.user or str(1))}, 'permission':'FULL_CONTROL'}]
		if cannedACL == 'public-read':
			acl.append({'grantee':{'userid':1}, 'permission':'read'})
		elif cannedACL == 'public-read-write':
			acl.append({'grantee':{'userid':1}, 'permission':'read'})
			acl.append({'grantee':{'userid':1}, 'permission':'write'})
		elif cannedACL == 'authenticated-read':
			acl.append({'grantee':{'userid':2}, 'permission':'read'})
		elif cannedACL != 'private':
			'''throw error'''
		acp['acl'] = acl
				
		result = Object.setObject( user = self.utakaReq.user,
			bucket = self.utakaReq.bucket, key=self.utakaReq.key,
			contentDisposition = self.utakaReq.req.headers_in.get('content-disposition'),
			contentEncoding = self.utakaReq.req.headers_in.get('content-encoding'),
			contentType = self.utakaReq.req.headers_in.get('content-type'),
			contentMd5 = self.utakaReq.req.headers_in.get('content-md5'),
			metadata = self.__getMetadata(),
			accessControlPolicy = acp,
			data = self.utakaReq.req.read())
Exemple #3
0
	def __putAclOperation(self):
		acp = AcpXml.fromXML(self.utakaReq.req.read())
		Object.setObjectACP(self.utakaReq.user, self.utakaReq.bucket, self.utakaReq.key, acp)
Exemple #4
0
	def __getAclOperation(self):
		object_acp = Object.getObjectACP(self.utakaReq.user, self.utakaReq.bucket, self.utakaReq.key)
		self.utakaReq.req.content_type = 'application/xml'
		self.utakaReq.write(AcpXml.toXML(object_acp))
Exemple #5
0
	def __deleteOperation(self):
		result = Object.destroyObject(key = self.utakaReq.key, bucket = self.utakaReq.bucket, user = self.utakaReq.user)
		self.utakaReq.req.status = 204