Name is required.
Email address is required.
Invalid email address
Answer is required.
Exceeding max length of 5KB

Jython Invalid bucket name s3://mocsdw01/FromFTP/

import boto3
BUCKET = FromFTP # name of the s3 bucket

file_key = 'AIP5_DLY_PCO_PO_20180714202419.asc.txt'

s3 = boto3.resource('s3')

obj = s3.Object(BUCKET, file_key)
for line in obj.get()['Body']._raw_stream:
print(line)

botocore.exceptions.ParamValidationError: Parameter validation failed:
Invalid bucket name "s3://mocsdw01/FromFTP/": Bucket name must match the regex "^[a-zA-Z0-9.\-_]{1,255}$" in <script> at line number 23

4 Community Answers

Matillion Agent  

Ian Funnell —

Hi Dmitriy,

Do you get the same error if you remove the s3:// prefix from the bucket name?

Best regards,
Ian


Dmitriy (Consultant) Burtsev —

botocore.exceptions.ParamValidationError: Parameter validation failed:
Invalid bucket name "mocsdw01/FromFTP": Bucket name must match the regex "^[a-zA-Z0-9.\-_]{1,255}$" in <script> at line number 23

This is the bucket URL: https://mocsdw01.s3.amazonaws.com/FromFTP/


Matillion Agent  

Kalyan Arangam —

hi Dmitry,

If i read it right, bucket name is just *mocsdw01".
“FromFTP” is the name of subfolder or Key.

See if the following helps -

import boto3
BUCKET = 'mocsdw01' # name of the s3 bucket

file_key = 'FromFTP/AIP5_DLY_PCO_PO_20180714202419.asc.txt'

s3 = boto3.resource('s3')

obj = s3.Object(BUCKET, file_key)
for line in obj.get()['Body']._raw_stream:
print(line)

#————————————————————-

Best
Kalyan


Dmitriy (Consultant) Burtsev —

It works.
Thank you

Post Your Community Answer

To add an answer please login