Example #1
0
                header_caps = header_key.title()
                metadata[header_caps] = request.headers[header_key]

        file_obj.put_metadata(metadata)
        return response_class(request=request)

    def PUT(self, request):
        """Handle HTTP PUT requests for the Swift Object Server."""
        try:
            device, partition, account, container, obj = \
                split_path(unquote(request.path), 5, 5, True)
        except ValueError, err:
            return HTTPBadRequest(body=str(err), request=request,
                        content_type='text/plain')
        if self.mount_check and not check_mount(self.devices, device):
            if not check_valid_account(account, self.fs_object):
                return Response(status='507 %s is not mounted' % device)
        if 'x-timestamp' not in request.headers or \
                    not check_float(request.headers['x-timestamp']):
            return HTTPBadRequest(body='Missing timestamp', request=request,
                        content_type='text/plain')
        error_response = check_object_creation(request, obj)
        if error_response:
            return error_response

        file_obj = DiskFile(self.devices, device, partition, account, container,
                            obj, self.logger, disk_chunk_size=self.disk_chunk_size, \
                            uid=request.headers['uid'], gid=request.headers['gid'])
        #TODO: Handle creation of marker objs.

        if not file_obj.is_valid:
Example #2
0
            return HTTPNotFound()

    def PUT(self, req):
        """Handle HTTP PUT request."""
        try:
            drive, part, account, container, obj = split_path(
                unquote(req.path), 4, 5, True)
        except ValueError, err:
            return HTTPBadRequest(body=str(err), content_type='text/plain',
                                request=req)
        if 'x-timestamp' not in req.headers or \
                    not check_float(req.headers['x-timestamp']):
            return HTTPBadRequest(body='Missing timestamp', request=req,
                        content_type='text/plain')
        if self.mount_check and not check_mount(self.root, drive):
            if not check_valid_account(account.replace(RESELLER_PREFIX, '', 1)):
                return Response(status='507 %s is not mounted' % drive)
        timestamp = normalize_timestamp(req.headers['x-timestamp'])
        #TODO: Store this timestamp as created time if container doesn't exists.
        if not obj:
            dir_obj = DiskDir(self.root, drive, part, account, container, self.logger, \
                              uid = req.headers['uid'], gid = req.headers['gid'])
        else:
            dir_obj = DiskDir(self.root, drive, part, account, container, self.logger)
            
        created = not dir_obj.dir_exists
        if obj: #put object in container
            if dir_obj.dir_exists:
                dir_obj.put_obj(int(req.headers['x-content-length']),
                                req.headers['x-timestamp'])
                return HTTPCreated(request=req)