Asynchronously uses S3’s internal
CopyObject
to copy objects within or between buckets. To copy objects between buckets, the
credentials must have permission to read the source object and write to the target
object. If the credentials do not have those permissions, try using
S3Bucket.stream_from.Added in prefect-aws==0.5.3.Args:
source_path: The path to the object to copy. Can be a string or Path.
target_path: The path to copy the object to. Can be a string or Path.
source_bucket_name: The bucket to copy the object from.
aws_credentials: Credentials to use for authentication with AWS.
target_bucket_name: The bucket to copy the object to. If not provided, defaults
to source_bucket.
**copy_kwargs: Additional keyword arguments to pass to S3Client.copy_object.
Returns:
The path that the object was copied to. Excludes the bucket name.
Examples:Copy notes.txt from s3://my-bucket/my_folder/notes.txt to
s3://my-bucket/my_folder/notes_copy.txt.
Uses S3’s internal
CopyObject
to copy objects within or between buckets. To copy objects between buckets, the
credentials must have permission to read the source object and write to the target
object. If the credentials do not have those permissions, try using
S3Bucket.stream_from.Args:
source_path: The path to the object to copy. Can be a string or Path.
target_path: The path to copy the object to. Can be a string or Path.
source_bucket_name: The bucket to copy the object from.
aws_credentials: Credentials to use for authentication with AWS.
target_bucket_name: The bucket to copy the object to. If not provided, defaults
to source_bucket.
**copy_kwargs: Additional keyword arguments to pass to S3Client.copy_object.
Returns:
The path that the object was copied to. Excludes the bucket name.
Examples:Copy notes.txt from s3://my-bucket/my_folder/notes.txt to
s3://my-bucket/my_folder/notes_copy.txt.
Asynchronously moves an object from one S3 location to another. To move objects
between buckets, the credentials must have permission to read and delete the source
object and write to the target object. If the credentials do not have those
permissions, this method will raise an error. If the credentials have permission to
read the source object but not delete it, the object will be copied but not deleted.Added in prefect-aws==0.5.3.Args:
source_path: The path of the object to move
target_path: The path to move the object to
source_bucket_name: The name of the bucket containing the source object
aws_credentials: Credentials to use for authentication with AWS.
target_bucket_name: The bucket to copy the object to. If not provided, defaults
to source_bucket.
Returns:
The path that the object was moved to. Excludes the bucket name.
Move an object from one S3 location to another. To move objects between buckets,
the credentials must have permission to read and delete the source object and write
to the target object. If the credentials do not have those permissions, this method
will raise an error. If the credentials have permission to read the source object
but not delete it, the object will be copied but not deleted.Args:
source_path: The path of the object to move
target_path: The path to move the object to
source_bucket_name: The name of the bucket containing the source object
aws_credentials: Credentials to use for authentication with AWS.
target_bucket_name: The bucket to copy the object to. If not provided, defaults
to source_bucket.
Returns:
The path that the object was moved to. Excludes the bucket name.
Asynchronously copies a folder from the configured S3 bucket to a local directory.Defaults to copying the entire contents of the block’s basepath to the current
working directory.Args:
from_path: Path in S3 bucket to download from. Defaults to the block’s
configured basepath.
local_path: Local path to download S3 contents to. Defaults to the current
working directory.
Asynchronously uses S3’s internal CopyObject and DeleteObject to move objects
within or between buckets. To move objects between buckets, self’s credentials
must have permission to read and delete the source object and write to the target
object. If the credentials do not have those permissions, this method will raise
an error. If the credentials have permission to read the source object but not
delete it, the object will be copied but not deleted.Args:
from_path: The path of the object to move.
to_path: The path to move the object to.
to_bucket: The bucket to move to. Defaults to the current bucket.
Returns:
The path that the object was moved to. Excludes the bucket name.
Examples:Move notes.txt from my_folder/notes.txt to my_folder/notes_copy.txt.
from prefect_aws.s3 import S3Buckets3_bucket = S3Bucket.load("my-bucket")await s3_bucket.amove_object("my_folder/notes.txt", "my_folder/notes_copy.txt")
Move notes.txt from my_folder/notes.txt to my_folder/notes_copy.txt in
another bucket.
from prefect_aws.s3 import S3Buckets3_bucket = S3Bucket.load("my-bucket")await s3_bucket.amove_object( "my_folder/notes.txt", "my_folder/notes_copy.txt", to_bucket="other-bucket")
Asynchronously uploads a directory from a given local path to the configured S3 bucket in a
given folder.Defaults to uploading the entire contents the current working directory to the
block’s basepath.Args:
local_path: Path to local directory to upload from.
to_path: Path in S3 bucket to upload to. Defaults to block’s configured
basepath.
ignore_file: Path to file containing gitignore style expressions for
filepaths to ignore.
Asynchronously streams an object from another bucket to this bucket. Requires the
object to be downloaded and uploaded in chunks. If self’s credentials
allow for writes to the other bucket, try using S3Bucket.copy_object.
Added in version 0.5.3.Args:
bucket: The bucket to stream from.
from_path: The path of the object to stream.
to_path: The path to stream the object to. Defaults to the object’s name.
**upload_kwargs: Additional keyword arguments to pass to
Client.upload_fileobj.
Returns:
The path that the object was uploaded to.
Examples:Stream notes.txt from your-bucket/notes.txt to my-bucket/landed/notes.txt.
Asynchronously uploads files within a folder (excluding the folder itself)
to the object storage service folder. Added in version prefect-aws==0.5.3.Args:
from_folder: The path to the folder to upload from.
to_folder: The path to upload the folder to.
**upload_kwargs: Additional keyword arguments to pass to
Client.upload_fileobj.
Returns:
The path that the folder was uploaded to.
Examples:Upload contents from my_folder to new_folder.
from prefect_aws.s3 import S3Buckets3_bucket = S3Bucket.load("my-bucket")await s3_bucket.aupload_from_folder("my_folder", "new_folder")
Asynchronously writes to an S3 bucket.Args:path: The key name. Each object in your bucket has a unique
key (or key name).
content: What you are uploading to S3.Example:Write data to the path dogs/small_dogs/havanese in an S3 Bucket:
Uses S3’s internal
CopyObject
to copy objects within or between buckets. To copy objects between buckets,
self’s credentials must have permission to read the source object and write
to the target object. If the credentials do not have those permissions, try
using S3Bucket.stream_from.Args:
from_path: The path of the object to copy.
to_path: The path to copy the object to.
to_bucket: The bucket to copy to. Defaults to the current bucket.
**copy_kwargs: Additional keyword arguments to pass to
S3Client.copy_object.
Returns:
The path that the object was copied to. Excludes the bucket name.
Examples:Copy notes.txt from my_folder/notes.txt to my_folder/notes_copy.txt.
from prefect_aws.s3 import S3Buckets3_bucket = S3Bucket.load("my-bucket")s3_bucket.copy_object("my_folder/notes.txt", "my_folder/notes_copy.txt")
Copy notes.txt from my_folder/notes.txt to my_folder/notes_copy.txt in
another bucket.
from prefect_aws.s3 import S3Buckets3_bucket = S3Bucket.load("my-bucket")s3_bucket.copy_object( "my_folder/notes.txt", "my_folder/notes_copy.txt", to_bucket="other-bucket")
Copies a folder from the configured S3 bucket to a local directory.Defaults to copying the entire contents of the block’s basepath to the current
working directory.Args:
from_path: Path in S3 bucket to download from. Defaults to the block’s
configured basepath.
local_path: Local path to download S3 contents to. Defaults to the current
working directory.
Uses S3’s internal CopyObject and DeleteObject to move objects within or
between buckets. To move objects between buckets, self’s credentials must
have permission to read and delete the source object and write to the target
object. If the credentials do not have those permissions, this method will raise
an error. If the credentials have permission to read the source object but not
delete it, the object will be copied but not deleted.Args:
from_path: The path of the object to move.
to_path: The path to move the object to.
to_bucket: The bucket to move to. Defaults to the current bucket.
Returns:
The path that the object was moved to. Excludes the bucket name.
Examples:Move notes.txt from my_folder/notes.txt to my_folder/notes_copy.txt.
from prefect_aws.s3 import S3Buckets3_bucket = S3Bucket.load("my-bucket")s3_bucket.move_object("my_folder/notes.txt", "my_folder/notes_copy.txt")
Move notes.txt from my_folder/notes.txt to my_folder/notes_copy.txt in
another bucket.
from prefect_aws.s3 import S3Buckets3_bucket = S3Bucket.load("my-bucket")s3_bucket.move_object( "my_folder/notes.txt", "my_folder/notes_copy.txt", to_bucket="other-bucket")
Uploads a directory from a given local path to the configured S3 bucket in a
given folder.Defaults to uploading the entire contents the current working directory to the
block’s basepath.Args:
local_path: Path to local directory to upload from.
to_path: Path in S3 bucket to upload to. Defaults to block’s configured
basepath.
ignore_file: Path to file containing gitignore style expressions for
filepaths to ignore.
Streams an object from another bucket to this bucket. Requires the
object to be downloaded and uploaded in chunks. If self’s credentials
allow for writes to the other bucket, try using S3Bucket.copy_object.Args:
bucket: The bucket to stream from.
from_path: The path of the object to stream.
to_path: The path to stream the object to. Defaults to the object’s name.
**upload_kwargs: Additional keyword arguments to pass to
Client.upload_fileobj.
Returns:
The path that the object was uploaded to.
Examples:Stream notes.txt from your-bucket/notes.txt to my-bucket/landed/notes.txt.
Writes to an S3 bucket.Args:path: The key name. Each object in your bucket has a unique
key (or key name).
content: What you are uploading to S3.Example:Write data to the path dogs/small_dogs/havanese in an S3 Bucket: