Skip to content

Commit ab71790

Browse files
s3_handler updates
1 parent c0c5acf commit ab71790

File tree

3 files changed

+16
-12
lines changed

3 files changed

+16
-12
lines changed

ObjectStores/s3_handler.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
LOG_FILE_NAME = 'output.log'
99

10+
# Change region to match with the default region that you setup when configuring your AWS CLI
1011
REGION = 'us-west-2'
1112

1213
class S3Handler:
@@ -28,7 +29,7 @@ def help(self):
2829
print("3. download <dest_object_name> <bucket_name> [<source_file_name>]")
2930
print("4. delete <dest_object_name> <bucket_name>")
3031
print("5. deletedir <bucket_name>")
31-
print("6. find <file_extension> [<bucket_name>] -- e.g.: 1. find txt 2. find txt bucket1 --")
32+
print("6. find <pattern> <bucket_name> -- e.g.: find txt bucket1 --")
3233
print("7. listdir [<bucket_name>]")
3334

3435
def _error_messages(self, issue):
@@ -106,7 +107,6 @@ def upload(self, source_file_name, bucket_name, dest_object_name=''):
106107

107108
# 3. SDK call
108109
# - When uploading the source_file_name and add it to object's meta-data
109-
# - Use self._get_file_extension() method to get the extension of the file.
110110

111111
# Success response
112112
# operation_successful = ('File %s uploaded to directory %s.' % (source_file_name, bucket_name))
@@ -146,7 +146,7 @@ def deletedir(self, bucket_name):
146146
return self._error_messages('not_implemented')
147147

148148

149-
def find(self, file_extension, bucket_name=''):
149+
def find(self, pattern, bucket_name=''):
150150
# Return object names that match the given file extension
151151

152152
# If bucket_name is specified then search for objects in that bucket.
@@ -196,9 +196,9 @@ def dispatch(self, command_string):
196196
bucket_name = ''
197197
response = self.deletedir(bucket_name)
198198
elif parts[0] == 'find':
199-
file_extension = ''
199+
pattern = ''
200200
bucket_name = ''
201-
response = self.find(file_extension, bucket_name)
201+
response = self.find(pattern, bucket_name)
202202
elif parts[0] == 'listdir':
203203
bucket_name = ''
204204
response = self.listdir(bucket_name)

README.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Steps
99

1010
1) Create virtual environment
1111

12-
$ virtualenv venv
12+
$ python3 -m venv venv
1313

1414
$ source venv/bin/activate
1515

@@ -32,10 +32,15 @@ AWS setup
3232
1) Sign up for AWS
3333

3434
2) Add AWS IAM user:
35-
Login to AWS Dashboard -> My Security Credentials -> Continue to Security Credentials -> Users -> Add User
36-
37-
3) Add permission to the user created:
38-
Select user -> Add permissions -> Attach existing policies directly -> Search for "AmazonEC2FullAccess"
35+
Go to IAM (Search in search box on the top) ->
36+
Users -> Add User -> Select Access Key - Programmatic access for credential type
37+
38+
For permission boundary, select Create user without a permissions
39+
boundary. Then click next to create a user.
40+
41+
After user is created, add permission : Select user -> Add
42+
permissions -> Attach existing policies directly -> Search for
43+
"AmazonS3FullAccess"
3944

4045
4) Do AWS setup in your local account to allow SDK access to AWS.
4146
The sample examples will guide you through the setup process. You will be asked to enter
@@ -70,4 +75,4 @@ Examples
7075

7176
4) DynamoDB:
7277
- Starter code for working with AWS DynamoDB
73-
- Grant AmazonDynamoDBFullAccess to your IAM Service Account / User
78+
- Grant AmazonDynamoDBFullAccess to your IAM Service Account / User

requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
requests
2-
gevent
32
boto3
43
pyparsing
54
six

0 commit comments

Comments
 (0)