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.

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.