Exemplo n.º 1
0
def copy_to_s3(file_uuid):
  try:
    # do additional processing,i.e add certain effects
    print("Copying to S3 file uuid" + file_uuid)
    file = File(file_uuid);
    file.copy(None, 'bucner123', 'true');
  except Exception, e:
         print (e.message);
    def test_remote_copy_source(self, request):
        request.return_value = {}

        # uuid with no effects
        f = File('a771f854-c2cb-408a-8c36-71af77811f3b')
        f.copy(target='tgt')
        request.assert_called_with('POST', 'files/', data={
            "source": "a771f854-c2cb-408a-8c36-71af77811f3b/",
            "target": "tgt"})

        # uuid with effects
        f = File('a771f854-c2cb-408a-8c36-71af77811f3b')
        f.copy(target='tgt', effects='resize/1x1/')
        request.assert_called_with('POST', 'files/', data={
            "source": "a771f854-c2cb-408a-8c36-71af77811f3b/-/resize/1x1/",
            "target": "tgt"})

        # cdn url with no effects
        f = File('a771f854-c2cb-408a-8c36-71af77811f3b/-/resize/2x2/')
        f.copy(target='tgt')
        request.assert_called_with('POST', 'files/', data={
            "source": "a771f854-c2cb-408a-8c36-71af77811f3b/-/resize/2x2/",
            "target": "tgt"})

        # cdn url with effects
        f = File('a771f854-c2cb-408a-8c36-71af77811f3b/-/resize/3x3/')
        f.copy(target='tgt', effects='flip/')
        request.assert_called_with('POST', 'files/', data={
            "source": "a771f854-c2cb-408a-8c36-71af77811f3b/-/resize/3x3/-/flip/",
            "target": "tgt"})
Exemplo n.º 3
0
    def test_remote_copy_source(self, request):
        request.return_value = {}

        # uuid with no effects
        f = File("a771f854-c2cb-408a-8c36-71af77811f3b")
        f.copy(target="tgt")
        request.assert_called_with(
            "POST", "files/", data={"source": "a771f854-c2cb-408a-8c36-71af77811f3b/", "target": "tgt"}
        )

        # uuid with effects
        f = File("a771f854-c2cb-408a-8c36-71af77811f3b")
        f.copy(target="tgt", effects="resize/1x1/")
        request.assert_called_with(
            "POST", "files/", data={"source": "a771f854-c2cb-408a-8c36-71af77811f3b/-/resize/1x1/", "target": "tgt"}
        )

        # cdn url with no effects
        f = File("a771f854-c2cb-408a-8c36-71af77811f3b/-/resize/2x2/")
        f.copy(target="tgt")
        request.assert_called_with(
            "POST", "files/", data={"source": "a771f854-c2cb-408a-8c36-71af77811f3b/-/resize/2x2/", "target": "tgt"}
        )

        # cdn url with effects
        f = File("a771f854-c2cb-408a-8c36-71af77811f3b/-/resize/3x3/")
        f.copy(target="tgt", effects="flip/")
        request.assert_called_with(
            "POST",
            "files/",
            data={"source": "a771f854-c2cb-408a-8c36-71af77811f3b/-/resize/3x3/-/flip/", "target": "tgt"},
        )
Exemplo n.º 4
0
def copy_to_s3(file_uuid):
    try:
        # do additional processing,i.e add certain effects
        print("Copying to S3 file uuid " + file_uuid)
        logger.info("In the process of copying fileUUID " + str(file_uuid))
        file = File(file_uuid)
        response = file.copy(None, 'bucner123', 'true')
    except Exception, e:
        logger.info("An error while copying file to s3 storage: " + str(e))
Exemplo n.º 5
0
    def test_remote_copy_source(self, request):
        request.return_value = {}

        # uuid with no effects
        f = File('a771f854-c2cb-408a-8c36-71af77811f3b')
        f.copy(target='tgt')
        request.assert_called_with('POST',
                                   'files/',
                                   data={
                                       "source":
                                       "a771f854-c2cb-408a-8c36-71af77811f3b/",
                                       "target": "tgt"
                                   })

        # uuid with effects
        f = File('a771f854-c2cb-408a-8c36-71af77811f3b')
        f.copy(target='tgt', effects='resize/1x1/')
        request.assert_called_with(
            'POST',
            'files/',
            data={
                "source": "a771f854-c2cb-408a-8c36-71af77811f3b/-/resize/1x1/",
                "target": "tgt"
            })

        # cdn url with no effects
        f = File('a771f854-c2cb-408a-8c36-71af77811f3b/-/resize/2x2/')
        f.copy(target='tgt')
        request.assert_called_with(
            'POST',
            'files/',
            data={
                "source": "a771f854-c2cb-408a-8c36-71af77811f3b/-/resize/2x2/",
                "target": "tgt"
            })

        # cdn url with effects
        f = File('a771f854-c2cb-408a-8c36-71af77811f3b/-/resize/3x3/')
        f.copy(target='tgt', effects='flip/')
        request.assert_called_with(
            'POST',
            'files/',
            data={
                "source":
                "a771f854-c2cb-408a-8c36-71af77811f3b/-/resize/3x3/-/flip/",
                "target": "tgt"
            })