Example #1
0
def begin():
    try:
        lib = Uploader()  # here set temp path and init everytime with it
        return lib.init(
            ENCODING_UPLOAD_PATH, str(bottle.request.forms.get('fileName')),
            int(bottle.request.forms.get('fileSize'))).get_result()
    except UploadException as ex:
        return InitResponse.init_error(DataPack(), ex).get_result()
 def _mock_data(self) -> DataPack:
     return DataPack().set_data(
         'abcdef',
         self._get_test_dir() + 'abcdef',
         123456,
         12,
         64,
         7
     )
Example #3
0
def view_begin(request):
    try:
        lib = Uploader()  # here set temp path and init everytime with it
        return JsonResponse(
            lib.init(ENCODING_UPLOAD_PATH, str(request.POST.get('fileName')),
                     int(request.POST.get('fileSize'))).get_result())
    except UploadException as ex:
        return JsonResponse(
            InitResponse.init_error(DataPack(), ex).get_result())
Example #4
0
def truncate():
    try:
        lib = Uploader()
        return lib.truncate_from(
            str(bottle.request.forms.get('sharedKey')),
            int(bottle.request.forms.get('segment'))).get_result()
    except UploadException as ex:
        return TruncateResponse.init_error(
            str(bottle.request.forms.get('sharedKey')), DataPack(),
            ex).get_result()
Example #5
0
def view_truncate(request):
    try:
        lib = Uploader()
        return JsonResponse(
            lib.truncate_from(str(request.POST.get('sharedKey')),
                              int(request.POST.get('segment'))).get_result())
    except UploadException as ex:
        return JsonResponse(
            TruncateResponse.init_error(str(request.POST.get('sharedKey')),
                                        DataPack(), ex).get_result())
Example #6
0
def part():
    try:
        lib = Uploader()
        return lib.upload(
            str(bottle.request.forms.get('sharedKey')),
            bytes(base64.b64decode(
                bottle.request.forms.get('content')))).get_result()
    except UploadException as ex:
        return UploadResponse.init_error(
            str(bottle.request.forms.get('sharedKey')), DataPack(),
            ex).get_result()
Example #7
0
def view_part(request):
    try:
        lib = Uploader()
        return JsonResponse(
            lib.upload(str(request.POST.get('sharedKey')),
                       bytes(base64.b64decode(
                           request.POST.get('content')))).get_result())
    except UploadException as ex:
        return JsonResponse(
            UploadResponse.init_error(str(request.POST.get('sharedKey')),
                                      DataPack(), ex).get_result())
Example #8
0
def done():
    try:
        lib = Uploader()
        result = lib.done(str(bottle.request.forms.get('sharedKey')))
        # check uploaded content and move it on drive
        print([result.get_temporary_location(), result.get_file_name()])
        # answer to client
        return result.get_result()
    except UploadException as ex:
        return DoneResponse.init_error(
            str(bottle.request.forms.get('sharedKey')), DataPack(),
            ex).get_result()