ECS: How to Perform Basic S3 Operations Using the "s3curl.pl" Script
Summary: How to perform basic s3 operations on ECS 3.x using the "s3curl" script.
This article applies to
This article does not apply to
This article is not tied to any specific product.
Not all product versions are identified in this article.
Instructions
Configuration Steps
Collect the following pieces of information in order to configure
s3curl.pl:
- Object user of the bucket you are investigating:
- Log in to the UI > Manage > Buckets > **Select namespace** > Write down the owner column for the bucket.
- Shared Secret of the object user:
- Log in to the UI > Manage > Users > **Edit** user from above > Write down the Shared Secret for the user.
- ECS Nodes data IP addresses or public IP addresses:
- Log in to the ECS CLI and run
getrackinfo -n
- Log in to the ECS CLI and run
If the client has network separation, you see IPs for data and repl from the above command. Write down the data IPs of the nodes.
Example:
Node ID Network Ip Address Netmask Gateway VLAN 5 repl 10.###.##.##4 255.255.252.0 - - 5 data 10.###.##.##2 255.255.252.0 -
If there is no network separation, get the public IP addresses of the nodes from
getrackinfo:
Example:
provo:/usr/share/s3curl # getrackinfo Node private Node Public RMM Ip Address Id Status Mac Ip Address Mac Ip Address Node Name =============== ====== ====== ================= ================= ================= ================= ========= 192.###.###.1 1 MA 00:1e:67:f1:85:10 10.##.##.##7 00:1e:67:bc:c5:53 10.##.##.##3 provo-red 192.###.###.2 2 SA 00:1e:67:ab:e6:d8 10.##.##.##8 00:1e:67:6a:08:8c 10.##.##.##4 sandy-red
Steps:
- Go to the directory
/usr/share/s3curlon the ECS node and check for the file below.
provo:/usr/share/s3curl # provo:/usr/share/s3curl # ls -lrt .s3curl -rw------- 1 root root 2095 Mar 6 16:14 .s3curl
- If the file does not exist, create it with the following content. ["
sample_user" is used.]
@endpoints = ECS data / public ip address gotten above.
%awsSecretAccessKeys = (
sample_user => {
id => '<Object User>',
key => '<Shared Secret>',
},
@endpoints = ('<node1_ip>','<node2_ip>','<node3_ip>','<node4_ip>',)
);
- You can add multiple users to this file like below.
%awsSecretAccessKeys = (
<sample_user> => {
id => '<object user>',
key => '<Shared Secret>',
},
<sample_user2> => {
id => '<object user>',
key => '<Shared Secret>',
},
@endpoints = ('<node1_ip>','<node2_ip>','<node3_ip>','<node4_ip>',)
);
- Changing the permissions of the files.
# sudo chmod 755 s3curl.pl # sudo chmod 600 .s3curl
Using s3curl.pl after Configuration
- Testing user authentication and list buckets owned by that user. "
bucket_1" is the name of the bucket.
--id= the ID set earlier in the.s3curlfile "sample_user"9020= TCP port used to connect to S3
# provo:/usr/share/s3curl # perl s3curl.pl --id <user ID> -- http://<hostname or IP>:9020 | xmllint --format -
provo:/usr/share/s3curl # perl s3curl.pl --id sample_user -- http://10.##.##.##7:9020 | xmllint --format -
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 421 100 421 0 0 21803 0 --:--:-- --:--:-- --:--:-- 22157
<?xml version="1.0" encloding="UTF-8" standalone="yes"?>
<ListAllMyBucketsResult xmlns="http://s3.amazonaws.com/doc/2006-03-01">
<Owner>
<ID>sample_user</ID>
<DisplayName>sample_user</DisplayName>
</Owner>
<Buckets>
<Bucket>
<Name>bucket_1</Name>
<CreationDate>2017-02-21T08:32:05.651Z</CreationDate>
<ServerSideEncryptionEnabled>false</ServerSideEncryptionEnabled>
</Bucket>
</Buckets>
<IsTruncated>false</IsTruncated>
</ListAllMyBucketsResult>
- Listing the contents of a specific bucket.
- A key in S3 refers to a file.
Note: S3 has a flatline file structure, directories do not exist.
s3curl.plonly shows the first 1000 files in a directory.
# perl s3curl.pl --id <user id> -- http://<hostname or IP>:9020/<bucket> | xmllint --format - | grep Key
provo:/usr/share/s3curl # perl s3curl.pl --id sample_user -- http://10.##.##.##7:9020/bucket_1 | xmllint --format - | grep Key
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 1128 100 1128 0 0 29386 0 --:--:-- --:--:-- --:--:-- 29684
<MaxKeys>1000</MaxKeys>
<Key>2017 - emea schedule obj storage.xlsx</Key>
<Key>_$folder$</Key>
<Key>dir1/dir2/dir3/test_new_name.txt</Key>
- Searching for a specific key or file in a bucket.
- Use the prefix search method to search for specific files once the beginning of the filename is known.
- Insert the method after the bucket name "
?prefix=<search_string>"
# perl s3curl.pl --id <user id> -- http://<hostname or IP>:9020/<bucket>?prefix=dir1/dir2/ | xmllint --format - | grep Key
provo:/usr/share/s3curl # perl s3curl.pl --id smaple_user -- http://10.##.##.##7:9020/bucket_1?prefix=dir1/dir2/ | xmllint --format - | grep Key
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 599 100 599 0 0 20309 0 --:--:-- --:--:-- --:--:-- 19966
<MaxKeys>1000</MaxKeys>
<Key>dir1/dir2/dir3/test_new_name.txt</Key>
- Reading a specific key or file in a bucket.
Note: If a key or bucket contains a space in its name, use the string "
%20" while querying that in the URL.
provo:/usr/share/s3curl # cat test1.txt Goodbye World provo:/usr/share/s3curl # perl s3curl.pl --id smaple_user -- http://10.##.##.##7:9020/bucket_1/dir1/dir2/dir3/test_new_name.txt Goodbye World
- Writing a specific key or file to the bucket.
provo:/usr/share/s3curl # cat test1.txt Goodbye World provo:/usr/share/s3curl # perl s3curl.pl --id smaple_user --put=test1.txt http://10.##.##.##7:9020/bucket_1/dir1/dir2/dir3/test_new_name.txt
- Read the metadata of a specific key or file in the bucket.
HTTP/1.1 200 OK--> Specific HTTP response for the requestx-amz-request-id-->request_idwhich can be tracked in the ECS logsETag--> MD5SUM of the fileContent-Length--> Size or number of bytes of the object
# perl s3curl.pl --id <user ID> --head http://<hostname or IP>:9020/<bucket>/<path1>/<path2>/<object>
provo:/usr/share/s3curl # perl s3curl.pl --id sample_user --head http://10.##.##.##7:9020/bucket_1/dir1/dir2/dir3/test_new_name.txt HTTP/1.1 200 OK Date: Wed, 08 Mar 2017 16:25:52 GMT Server: ViPR/1.0 x-amz-request-id: 0a3c23ed:15aa813368d:10e1:1 x-amz-id-2: 83769c2fcf5f8907b60b588a251bcc492d86d5829dfc2c8bee2504f0c527f256 ETag: "54aea9f06281a5df11d06f105c6fb039" Last-Modified: Wed, 08 Mar 2017 16:08:02 GMT x-emc-mtime: 1488989282859 Content-Encoding: identity Content-Type: application/octet-stream Content-Length: 14
- To create a new bucket for the user:
# perl s3curl.pl --id <user ID> --createBucket -- http://<hostname or IP>:9020/<new bucket name>
provo:/usr/share/s3curl # perl s3curl.pl --id sample_user --createBucket -- http://10.##.##.##7:9020/new_bucket_name New Bucket can be seen below. # provo:/usr/share/s3curl # perl s3curl.pl --id <user> -- http:/<hostname or IP>:9020 | xmllint --format - | grep -A1 '<Bucket>'
provo:/usr/share/s3curl # perl s3curl.pl --id sample_user -- http://10.##.##.##7:9020 | xmllint --format - | grep -A1 '<Bucket>'
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 583 100 583 0 0 31712 0 --:--:-- --:--:-- --:--:-- 32388
<Bucket>
<Name>new_bucket_name</Name>
--
<Bucket>
<Name>some_old_bucket</Name>
- Downloading a specific key or file in a bucket to an ECS node.
# perl s3curl.pl --id <user ID> -- http://<hostname or IP>:9020/<bucket>/<path1>/<object> -o download2.txt
provo:/usr/share/s3curl # perl s3curl.pl --id sample_user -- http://10.##.##.##7:9020/bucket_1/dir1/dir2/dir3/test_new_name.txt -o download2.txt
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 14 100 14 0 0 1360 0 --:--:-- --:--:-- --:--:-- 1400
provo:/usr/share/s3curl #
provo:/usr/share/s3curl # cat download2.txt
Goodbye World
- Deleting a specific key or file in the bucket belonging to the user.
provo:/usr/share/s3curl # perl s3curl.pl --id <user ID> --delete -- http://<hostname or IP>:9020/<bucket>/<path1>/<path2>/<object>
Note: If object name has a space in between, you must quote the whole path and add "
Example object name:
+ " in the space.
Example object name:
test_new_name test - test.txt
perl s3curl.pl --id sample_user --delete -- "http://10.##.##.##7:9020/bucket/dir1/dir2/test_new_name+test+-+test.txt"
- Deleting a bucket belong to the user.
provo:/usr/share/s3curl # perl s3curl.pl --id smaple_user --delete -- http://10.##.##.##7:9020/new_bucket_name
The bucket does not exist after listing the buckets belonging to the user:
provo:/usr/share/s3curl # perl s3curl.pl --id smaple_user -- http://10.##.##.##7:9020 | xmllint --format - | grep -A1 '<Bucket>'
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 421 100 421 0 0 19928 0 --:--:-- --:--:-- --:--:-- 21050
<Bucket>
<Name>bucket_1</Name>
- Partially read a file using "byte: range" Header (below the first seven characters are read)
- Range: bytes values include:
The first 500 bytes: "bytes 0-499/1234" The second 500 bytes: "bytes 500-999/1234" All except for the first 500 bytes: "bytes 500-1233/1234" The last 500 bytes: "bytes 734-1233/1234"
provo:/usr/share/s3curl # cat test1.txt Goodbye World provo:/usr/share/s3curl # perl s3curl.pl --id sample_user -- http://10.##.##.##7:9020/bucket_1/dir1/dir2/dir3/test_new_name.txt -H "Range: bytes=0-6" Goodbye Using the "--debug" option for more detailed responses.
Note: The debug option can be used for any of the
s3curl.pl commands.
# perl s3curl.pl --debug --id <user ID> -- http://<hostname>:9020/<bucket>/<object> -H "Range: bytes=0-6"
provo:/usr/share/s3curl # perl s3curl.pl --debug --id sample_user -- http://10.##.##.##7:9020/bucket_1/dir1/dir2/dir3/test_new_name.txt -H "Range: bytes=0-6" s3curl: Found the url: host=10.##.##.237; port=9020; uri=/thomas/dir1/dir2/dir3/test_new_name.txt; query=; s3curl: ordinary endpoint signing case s3curl: StringToSign='GET\n\n\nWed, 08 Mar 2017 17:10:59 +0000\n/bucket_1/dir1/dir2/dir3/test_new_name.txt' s3curl: exec curl -v -H 'Date: Wed, 08 Mar 2017 17:10:59 +0000' -H 'Authorization: AWS hegars5:+YrMhohkQ2HqRNkYURJMbddIwrA=' -L -H 'content-type: ' http://10.##.##.##7:9020/bucket_1/dir1/dir2/dir3/test_new_name.txt -H 'Range: bytes=0-6' * Hostname was NOT found in DNS cache * Trying 10.##.##.##7... * Connected to 10.##.##.##7 (10.##.##.##7) port 9020 (#0) > GET /bucket_1/dir1/dir2/dir3/test_new_name.txt HTTP/1.1 > User-Agent: curl/7.37.0 > Host: 10.##.##.##7:9020 > Accept: */* > Date: Wed, 08 Mar 2017 17:10:59 +0000 > Authorization: AWS hegars5:+YrMhohkQ2HqRNkYURJMbddIwrA= > Range: bytes=0-6 > < HTTP/1.1 206 Partial Content < Date: Wed, 08 Mar 2017 17:10:59 GMT < Content-Range: bytes 0-6/14 < Accept-Ranges: bytes * Server ViPR/1.0 is not blacklisted < Server: ViPR/1.0 < x-amz-request-id: 0a3c23ed:15aa813368d:10fc:1 < x-amz-id-2: 83769c2fcf5f8907b60b588a251bcc492d86d5829dfc2c8bee2504f0c527f256 < ETag: "54aea9f06281a5df11d06f105c6fb039" < Last-Modified: Wed, 08 Mar 2017 17:02:13 GMT < x-emc-mtime: 1488992533141 < Content-Encoding: identity < Content-Type: application/octet-stream < Content-Length: 7 < * Connection #0 to host 10.##.##.##7 left intact Goodbye
- Uploading a batch of files or keys to a specific bucket.
- Create a sample file.
# vi /usr/share/s3curl/test # cat /usr/share/s3curl/test
This file is uploaded 1000 times to ECS.
- Create the following script.
# vi /usr/share/s3curl/script.sh
#!/bin/bash
# script.sh
for i in {1..1000}
do
./s3curl.pl --id=sample_user --put="test" -- "http://10.##.##.##7:9020/bucket_1/File$(printf "%04d" "$i").txt"
echo "File$(printf "%04d" "$i").txt"
done
- Change the permissions of the script.
# cd /usr/share/s3curl # sudo chmod +755
- Run the script.
# sh script.s
- Writing a file with a space or special character
- Writing a file with a space character called "
test file.txt" (requires ASCII value %20)
provo:/usr/share/s3curl # perl s3curl.pl --id upload_test --put="test file.txt" -- http://10.##.##.##:9020/bucket_name/test%20file.txt
- Writing a file with a special character bracket called "
testfile (1).txt" (requires a slash "\" to ignore special character)
provo:/usr/share/s3curl # perl s3curl.pl --id upload_test --put="testfile (1).txt" -- http://10.##.##.##:9020/bucket_name/testfile%20\(1\).txt
Affected Products
Elastic Cloud StorageProducts
Elastic Cloud StorageArticle Properties
Article Number: 000014704
Article Type: How To
Last Modified: 20 Oct 2025
Version: 5
Find answers to your questions from other Dell users
Support Services
Check if your device is covered by Support Services.