Example #1
0
def swift_get_object(request, container_name, object_name, with_data=True):
    if with_data:
        headers, data = swift_api(request).get_object(container_name,
                                                      object_name)
    else:
        data = None
        headers = swift_api(request).head_object(container_name,
                                                 object_name)
    orig_name = headers.get("x-object-meta-orig-filename")
    timestamp = None
    try:
        ts_float = float(headers.get('x-timestamp'))
        timestamp = timeutils.iso8601_from_timestamp(ts_float)
    except Exception:
        pass
    obj_info = {
        'name': object_name,
        'bytes': headers.get('content-length'),
        'content_type': headers.get('content-type'),
        'etag': headers.get('etag'),
        'timestamp': timestamp,
    }
    return StorageObject(obj_info,
                         container_name,
                         orig_name=orig_name,
                         data=data)
Example #2
0
def swift_get_container(request, container_name, with_data=True):
    if with_data:
        headers, data = swift_api(request).get_object(container_name, "")
    else:
        data = None
        headers = swift_api(request).head_container(container_name)
    timestamp = None
    is_public = False
    public_url = None
    try:
        is_public = GLOBAL_READ_ACL in headers.get('x-container-read', '')
        if is_public:
            swift_endpoint = base.url_for(request,
                                          'object-store',
                                          endpoint_type='publicURL')
            public_url = swift_endpoint + '/' + urlparse.quote(container_name)
        ts_float = float(headers.get('x-timestamp'))
        timestamp = timeutils.iso8601_from_timestamp(ts_float)
    except Exception:
        pass
    container_info = {
        'name': container_name,
        'container_object_count': headers.get('x-container-object-count'),
        'container_bytes_used': headers.get('x-container-bytes-used'),
        'timestamp': timestamp,
        'data': data,
        'is_public': is_public,
        'public_url': public_url,
    }
    return Container(container_info)
Example #3
0
def swift_get_container(request, container_name, with_data=True):
    if with_data:
        headers, data = swift_api(request).get_object(container_name, "")
    else:
        data = None
        headers = swift_api(request).head_container(container_name)
    timestamp = None
    is_public = False
    public_url = None
    try:
        is_public = GLOBAL_READ_ACL in headers.get('x-container-read', '')
        if is_public:
            swift_endpoint = base.url_for(request,
                                          'object-store',
                                          endpoint_type='publicURL')
            public_url = swift_endpoint + '/' + urlparse.quote(container_name)
        ts_float = float(headers.get('x-timestamp'))
        timestamp = timeutils.iso8601_from_timestamp(ts_float)
    except Exception:
        pass
    container_info = {
        'name': container_name,
        'container_object_count': headers.get('x-container-object-count'),
        'container_bytes_used': headers.get('x-container-bytes-used'),
        'timestamp': timestamp,
        'data': data,
        'is_public': is_public,
        'public_url': public_url,
    }
    return Container(container_info)
Example #4
0
def swift_get_container(request, container_name):
    headers, data = swift_api(request).get_object(container_name, "")
    timestamp = None
    try:
        ts_float = float(headers.get('x-timestamp'))
        timestamp = timeutils.iso8601_from_timestamp(ts_float)
    except Exception:
        pass
    container_info = {
        'name': container_name,
        'container_object_count': headers.get('x-container-object-count'),
        'container_bytes_used': headers.get('x-container-bytes-used'),
        'timestamp': timestamp,
    }
    return Container(container_info)
def swift_get_container(request, container_name):
    headers, data = swift_api(request).get_object(container_name, "")
    timestamp = None
    try:
        ts_float = float(headers.get('x-timestamp'))
        timestamp = timeutils.iso8601_from_timestamp(ts_float)
    except Exception:
        pass
    container_info = {
        'name': container_name,
        'container_object_count': headers.get('x-container-object-count'),
        'container_bytes_used': headers.get('x-container-bytes-used'),
        'timestamp': timestamp,
    }
    return Container(container_info)