Posts

Showing posts with the label Amazon S3

AccessDenied For ListObjectsV2 Operation For S3 Bucket

Answer : I'm not sure the accepted answer is actually acceptable , as it simply allows all operations on the bucket. Also the Sid is misleading... ;-) This AWS article mentions the required permissions for aws s3 sync . This is how a corresponding policy looks like: { "Version": "version_id", "Statement": [ { "Sid": "AllowBucketSync", "Effect": "Allow", "Action": [ "s3:GetObject", "s3:PutObject", "s3:ListBucket" ], "Resource": [ "arn:aws:s3:::BUCKET-NAME", "arn:aws:s3:::BUCKET-NAME/*" ] } ] } Try to update your bucket policy to: { "Version": "version_id", "Statement": [ { "Sid": "AllowPublicRead", "Effect": "Allow", ...

Copy Multiple Files From S3 Bucket

Answer : Also one can use the --recursive option, as described in the documentation for cp command. It will copy all objects under a specified prefix recursively. Example: aws s3 cp s3://folder1/folder2/folder3 . --recursive will grab all files under folder1/folder2/folder3 and copy them to local directory. There is a bash script which can read all the filenames from a file filename.txt . #!/bin/bash set -e while read line do aws s3 cp s3://bucket-name/$line dest-path/ done <filename.txt You might want to use "sync" instead of "cp". The following will download/sync only the files with the ".txt" extension in your local folder: aws s3 sync --exclude="*" --include="*.txt" s3://mybucket/mysubbucket .

Amazon AWS Filezilla Transfer Permission Denied

Answer : To allow user ec2-user (Amazon AWS) write access to the public web directory (/var/www/html), enter this command via Putty or Terminal, as the root user sudo : chown -R ec2-user /var/www/html Make sure permissions on that entire folder were correct: chmod -R 755 /var/www/html Doc's: Setting up amazon ec2-instances Connect to Amazon EC2 file directory using Filezilla and SFTP (Video) Understanding and Using File Permissions if you are using centOs then use sudo chown -R centos:centos /var/www/html sudo chmod -R 755 /var/www/html For Ubuntu sudo chown -R ubuntu:ubuntu /var/www/html sudo chmod -R 755 /var/www/html For Amazon ami sudo chown -R ec2-user:ec2-user /var/www/html sudo chmod -R 755 /var/www/html In my case the /var/www/html in not a directory but a symbolic link to the /var/app/current, so you should change the real directoy ie /var/app/current: sudo chown -R ec2-user /var/app/current sudo chmod -R 755 /var/app/current I hope th...

Amazon S3 Console: Download Multiple Files At Once

Image
Answer : It is not possible through the AWS Console web user interface. But it's a very simple task if you install AWS CLI. You can check the installation and configuration steps on Installing in the AWS Command Line Interface After that you go to the command line: aws s3 cp --recursive s3://<bucket>/<folder> <local_folder> This will copy all the files from given S3 path to your given local path. If you use AWS CLI, you can use the exclude along with --include and --recursive flags to accomplish this aws s3 cp s3://path/to/bucket/ . --recursive --exclude "*" --include "things_you_want" Eg. --exclude "*" --include "*.txt" will download all files with .txt extension. More details - https://docs.aws.amazon.com/cli/latest/reference/s3/ Selecting a bunch of files and clicking Actions->Open opened each in a browser tab, and they immediately started to download (6 at a time).

AmazonS3Client(credentials) Is Deprecated

Answer : You can either use AmazonS3ClientBuilder or AwsClientBuilder as alternatives. For S3, simplest would be with AmazonS3ClientBuilder, BasicAWSCredentials creds = new BasicAWSCredentials("access_key", "secret_key"); AmazonS3 s3Client = AmazonS3ClientBuilder.standard().withCredentials(new AWSStaticCredentialsProvider(creds)).build(); Use the code listed below to create an S3 client without credentials: AmazonS3 s3Client = AmazonS3ClientBuilder.standard().build(); An usage example would be a lambda function calling S3. You need to pass the region information through the com.amazonaws.regions.Region object. Use AmazonS3Client(credentials, Region.getRegion(Regions.REPLACE_WITH_YOUR_REGION))

Copy Data From S3 To Local With Prefix

Answer : aws s3 cp s3://my-bucket/ <local directory path> --recursive --exclude "*" --include "<prefix>*" This will copy only files with given prefix The aws s3 cp command will not accept a wildcard as part of the filename (key). Instead, you must use the --include and --exclude parameters to define filenames. From: Use of Exclude and Include Filters Currently, there is no support for the use of UNIX style wildcards in a command's path arguments. However, most commands have --exclude "<value>" and --include "<value>" parameters that can achieve the desired result. These parameters perform pattern matching to either exclude or include a particular file or object. The following pattern symbols are supported. So, you would use something like: aws s3 cp s3://my-bucket-name/ . --include "RAW_TIMESTAMP_0506*" The above answers to not work properly... for example I have many thousands of files in a directo...

Content-type To Be Used For Uploading Svg Images To AWS S3

Answer : As you mentioned, the correct Content-Type for SVG files is "image/svg+xml". Even if the AWS console does not provide that value in the Content-Type selection field, you can enter it anyway and S3 will accept it. AWS specifies the following in their API docs for the Content-Type header: A standard MIME type describing the format of the contents. For more information, go to http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.17. Type: String Default: binary/octet-stream Valid Values: MIME types Constraints: None For additional details see http://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectPUT.html