1
# Copyright [2010] [Anso Labs, LLC]
3
# Licensed under the Apache License, Version 2.0 (the "License");
4
# you may not use this file except in compliance with the License.
5
# You may obtain a copy of the License at
7
# http://www.apache.org/licenses/LICENSE-2.0
9
# Unless required by applicable law or agreed to in writing, software
10
# distributed under the License is distributed on an "AS IS" BASIS,
11
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
# See the License for the specific language governing permissions and
13
# limitations under the License.
16
Properties of an object stored within a bucket.
19
from nova.exception import NotFound, NotAuthorized
25
def __init__(self, bucket, key):
26
""" wrapper class of an existing key """
29
self.path = bucket._object_path(key)
30
if not os.path.isfile(self.path):
34
return "<Object %s/%s>" % (self.bucket, self.key)
38
""" computes the MD5 of the contents of file """
39
with open(self.path, "r") as f:
40
return nova.crypto.compute_md5(f)
45
return os.path.getmtime(self.path)
48
""" read all contents of key into memory and return """
49
return self.file.read()
53
""" return a file object for the key """
54
return open(self.path, 'rb')
57
""" deletes the file """