Uploaded image for project: 'Libcloud'
  1. Libcloud
  2. LIBCLOUD-328

Creating a container with an '@', then creating object inside container encodes url twice

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 0.12.3
    • Fix Version/s: 0.13.0
    • Component/s: Storage
    • Labels:
      None
    • Environment:

      testing with cloudfiles

      Description

      Using sample code from documentation:

      container_name = 'david@statichacks.org'
      # Create a container if it doesn't already exist
      try:
          container = driver.get_container(container_name=container_name)
          print "Using existing container %s" % container_name
      except ContainerDoesNotExistError:
          container = driver.create_container(container_name=container_name)
          print "Created new container %s" % container_name
      
      print 'Uploading object...'
      
      content = { 'content_type' : 'audio' }
      # Compress data in our directory and stream it directly to CF
      obj = container.upload_object(file_name, object_name=object_name,
                      extra=content)
      

      Produces a double encoded URL for the upload_object call:

      URL: david%40statichacks.org
      Created new container david@statichacks.org
      Uploading object...
      URL: david%2540statichacks.org
      {'bytes_transferred': 4269,
       'data_hash': 'eb80d68c737781db10b748fd53ecdd22',
       'response': <libcloud.storage.drivers.cloudfiles.CloudFilesRawResponse object at 0x25d1310>}
      404
      {'date': 'Wed, 22 May 2013 15:06:58 GMT', 'content-length': '70', 'content-type': 'text/html; charset=UTF-8', 'x-trans-id': 'txa6557bd13bb14d1895154d4b36049a55'}
      

      I can avoid this by overwriting the container object in the above code with another 'get_container' call. But it seems like the code should just do the right thing when an object uploaded using an existing container.

        Activity

        Hide
        kami Tomaz Muraus added a comment -

        I agree, this definitely looks like a bug which should be fixed on our side.

        I'll look into it asap.

        Show
        kami Tomaz Muraus added a comment - I agree, this definitely looks like a bug which should be fixed on our side. I'll look into it asap.
        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit 1485839 from Tomaz Muraus
        [ https://svn.apache.org/r1485839 ]

        Fix an issue with double encoding the container name in the CloudFiles
        driver upload_object method.

        Also properly encode container and object name used in the HTTP request
        in the get_container and get_object method. For clarity rename current
        _clean* methods to _encode*.

        Fixes LIBCLOUD-328.

        Show
        jira-bot ASF subversion and git services added a comment - Commit 1485839 from Tomaz Muraus [ https://svn.apache.org/r1485839 ] Fix an issue with double encoding the container name in the CloudFiles driver upload_object method. Also properly encode container and object name used in the HTTP request in the get_container and get_object method. For clarity rename current _clean* methods to _encode*. Fixes LIBCLOUD-328 .
        Hide
        kami Tomaz Muraus added a comment -

        David Bryson I've pushed a change to trunk and 0.12.x which should fix this issue.

        Can you please confirm it and let us know if you encounter any other encoding related issues while retrieving or listing objects?

        Thanks

        Show
        kami Tomaz Muraus added a comment - David Bryson I've pushed a change to trunk and 0.12.x which should fix this issue. Can you please confirm it and let us know if you encounter any other encoding related issues while retrieving or listing objects? Thanks
        Hide
        dbryson David Bryson added a comment -

        I can confirm the code works as expected with the patch:

        Created new container david@statichacks.org
        Uploading object...
        Upload complete, transferred: 4 KB
        
        Show
        dbryson David Bryson added a comment - I can confirm the code works as expected with the patch: Created new container david@statichacks.org Uploading object... Upload complete, transferred: 4 KB
        Hide
        kami Tomaz Muraus added a comment -

        Thanks for confirming that the fix works.

        Show
        kami Tomaz Muraus added a comment - Thanks for confirming that the fix works.

          People

          • Assignee:
            kami Tomaz Muraus
            Reporter:
            dbryson David Bryson
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development