[SWift] Unable to download a file using S3 Rest API

asked 2015-07-01 17:23:26 -0600

arpit.agarwal gravatar image

updated 2015-07-01 17:24:24 -0600

I have set up a swift cluster and have users as

root@ip-172-31-10-112:/home/ubuntu# keystone user-list
+----------------------------------+-------+---------+------------------+
|                id                |  name | enabled |      email       |
+----------------------------------+-------+---------+------------------+
| 7a4e58061623422c8de321e75236531a | admin |   True  |                  |
| 7e738f06c68541e690e42818339722c4 |  demo |   True  |                  |
| e94a5691a33842e983671e1459493595 | swift |   True  |                  |
+----------------------------------+-------+---------+------------------+

I also have configured endpoints as

keystone endpoint-list
+----------------------------------+-----------+---------------------------------------------+---------------------------------------------+-----------------------------+----------------------------------+
|                id                |   region  |                  publicurl                  |                 internalurl                 |           adminurl          |            service_id            |
+----------------------------------+-----------+---------------------------------------------+---------------------------------------------+-----------------------------+----------------------------------+
| bd638e9c1de64d7eafa3462209524a82 | regionOne |          http://localhost:5000/v2.0         |          http://localhost:5000/v2.0         | http://localhost:35357/v2.0 | 4ae8623fe6394c07b501f04d4071c554 |
| fe141835230e407aa27d1b09f1dd2426 | regionOne | http://localhost:8080/v1/AUTH_%(tenant_id)s | http://localhost:8080/v1/AUTH_%(tenant_id)s |    http://localhost:8080    | 20caf69b5b2d46318dc466786bc76490 |
+----------------------------------+-----------+---------------------------------------------+---------------------------------------------+-----------------------------+----------------------------------+

Now I am trying to access this swift cluster by using s3 rest apis

client.setEndpoint("http://52.27.156.221:8080")
client.createBucket(bucket)
client.putObject(bucket, key,  new File(file))
val outStream =
      client.getObject(new GetObjectRequest(bucket, key)).getObjectContent

So using the s3 apis Upload and list buckets is working for me but the get call is failing with

Exception in thread "main" com.amazonaws.services.s3.model.AmazonS3Exception: Unauthorized (Service: Amazon S3; Status Code: 401; Error Code: 401 Unauthorized; Request ID: null), S3 Extended Request ID: null
    at com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:1127)
    at com.amazonaws.http.AmazonHttpClient.executeOneRequest(AmazonHttpClient.java:743)
    at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:462)

My ec2 credentials look like this on the swift proxy server

keystone ec2-credentials-list
+--------+----------------------------------+----------------------------------+
| tenant |              access              |              secret              |
+--------+----------------------------------+----------------------------------+
| admin  | 1a9f521658644d108e*******| 88b1ab13ecf******** |
| admin  | 1c3ca04955804b119******** | bb567940e39447e6855******* |
+--------+----------------------------------+----------------------------------+

any idea what am I doing wrong ?

edit retag flag offensive close merge delete

Comments

Have you added role to project for your user?

trangtriqc gravatar imagetrangtriqc ( 2020-03-29 01:45:11 -0600 )edit