5

I want to upload a file in Swift. I executed this code in python :

 import swiftclient
swift = swiftclient.client.Connection(auth_version='1',user='test:tester',key='testing',authurl='http://localhost:8080/auth/v1.0')
# Create the swift container
swift.put_container('cute-cats')
# Upload the object
with open('cat.jpg', 'rb') as f:
    file_data = f.read()
swift.put_object('cute-cats', 'cat.jpg', file_data)

# List the containers
print swift.head_account()

# List the objects in the cute cats containers
print swift.head_container('cute-cats')

The code is running, but, how can I check if the file is stored in swift ? The file does not exist in the folder Swift.

Thank you.

Amelie
  • 535
  • 1
  • 5
  • 13

1 Answers1

1

From terminal you can run a simple curl:

$ curl http://localhost:8080/v1/AUTH_test/cute-cats/cat.jpg

If you want to test using python code, you can use the lib requests1.

The file does not exist in the folder Swift.

Which folder do you mean? Swift usually store its objects(files) using a hash, so to find the objects you gonna need a command like swift-get-nodes.

Nelson Marcos
  • 477
  • 2
  • 16