示例#1
0
    def get_info(self):
        """
        Returns Object-Count and Bytes-Used.
        """

        if not os.path.isdir(self.datadir):
            return

        files = do_listdir(self.datadir)
        files_count = len(files)
        for file in files:
            dir_bytes_used += do_stat(self.datadir + '/' + file).st_size

        return files_count, dir_bytes_used
示例#2
0
                return Response(status='499 Client Disconnect')
            etag = etag.hexdigest()
            if 'etag' in request.headers and \
                            request.headers['etag'].lower() != etag:
                logging.error('Etag mismatch %s %s %s' % (account, container, obj))
                return HTTPUnprocessableEntity(request=request)

            content_type = request.headers['content-type']
            if not content_type:
                content_type = FILE_TYPE

            metadata = {
                X_TIMESTAMP: request.headers['x-timestamp'],
                X_CONTENT_TYPE: content_type,
                X_ETAG: etag,
                X_CONTENT_LENGTH: str(do_stat(fd).st_size),
                X_TYPE: OBJECT,
                X_OBJECT_TYPE: FILE,
            }

            if request.headers['content-type'].lower() == DIR_TYPE:
                metadata.update({X_OBJECT_TYPE: MARKER_DIR})

            metadata.update(val for val in request.headers.iteritems()
                    if val[0].lower().startswith('x-object-meta-') and
                    len(val[0]) > 14)
            for header_key in self.allowed_headers:
                if header_key in request.headers:
                    header_caps = header_key.title()
                    metadata[header_caps] = request.headers[header_key]
            if not file_obj.put(fd, tmppath, metadata):