Пример #1
0
def put_file(request, storage_index=None, write_enabler=None):
    '''Handles HTTP PUT requests for new or existing files.

    If write_enabler is provided, it is further processed as an mutable
    file/directory.

    '''

    if _clean_input(storage_index) is not None:
        if request.PUT is not None:
            try:
                content_length = request.ENV['CONTENT_LENGTH']
                save_status = save_file(storage_index, request.PUT,
                                        content_length,
                                        _clean_input(write_enabler))

                return Response(status_code=save_status)
            except FileSystemException, e:
                return Response(e.text, status_code=e.code)
Пример #2
0
def put_file(request, storage_index=None, write_enabler=None):
    '''Handles HTTP PUT requests for new or existing files.

    If write_enabler is provided, it is further processed as an mutable
    file/directory.

    '''

    if _clean_input(storage_index) is not None:
        if request.PUT is not None:
            try:
                content_length = request.ENV['CONTENT_LENGTH']
                save_status = save_file(
                    storage_index,
                    request.PUT,
                    content_length,
                    _clean_input(write_enabler)
                    )

                return Response(status_code=save_status)
            except FileSystemException, e:
                return Response(e.text, status_code=e.code)
Пример #3
0
def get_file(request, storage_index=None):
    '''Handles GET requests for encrypted files.

    IANA manages a registry of media types,
    http://www.iana.org/assignments/media-types/

    '''
    if _clean_input(storage_index) is not None:
        try:
            file_to_send, size = retrieve_file(storage_index)
        except FileSystemException, e:
            return Response(e.text, status_code=e.code)

        headers = [('Content-Type', 'application/octet-stream'),
                   ('Content-Length', str(size))]
        return Response(file_to_send, headers)
Пример #4
0
def get_file(request, storage_index=None):
    '''Handles GET requests for encrypted files.

    IANA manages a registry of media types,
    http://www.iana.org/assignments/media-types/

    '''
    if _clean_input(storage_index) is not None:
        try:
            file_to_send, size = retrieve_file(storage_index)
        except FileSystemException, e:
            return Response(e.text, status_code=e.code)

        headers = [('Content-Type', 'application/octet-stream'),
                   ('Content-Length', str(size))]
        return Response(file_to_send, headers)