copy_dir¶
- ltdconveyor.s3.copy_dir(bucket_name, src_path, dest_path, aws_access_key_id=None, aws_secret_access_key=None, aws_profile=None, surrogate_key=None, cache_control=None, surrogate_control=None, create_directory_redirect_object=True)¶
Copy objects from one directory in a bucket to another directory in the same bucket.
Object metadata is preserved while copying, with the following exceptions:
If a new surrogate key is provided it will replace the original one.
If
cache_control
andsurrogate_control
values are provided they will replace the old one.
- Parameters:
bucket_name (
str
) – Name of an S3 bucket.src_path (
str
) – Source directory in the S3 bucket. Thesrc_path
should ideally end in a trailing'/'
. E.g.'dir/dir2/'
.dest_path (
str
) – Destination directory in the S3 bucket. Thedest_path
should ideally end in a trailing'/'
. E.g.'dir/dir2/'
. The destination path cannot contain the source path.aws_access_key_id (
str
) – The access key for your AWS account. Also setaws_secret_access_key
.aws_secret_access_key (
str
) – The secret key for your AWS account.aws_profile (
str
, optional) – Name of AWS profile in~/.aws/credentials
. Use this instead ofaws_access_key_id
andaws_secret_access_key
for file-based credentials.surrogate_key (
str
, optional) – The surrogate key to insert in the header of all objects in thex-amz-meta-surrogate-key
field. This key is used to purge builds from the Fastly CDN when Editions change. IfNone
then no header will be set. If the object already has ax-amz-meta-surrogate-key
header then it will be replaced.cache_control (
str
, optional) – This sets (and overrides) theCache-Control
header on the copied files. TheCache-Control
header specifically dictates how content is cached by the browser (ifsurrogate_control
is also set).surrogate_control (
str
, optional) – This sets (and overrides) thex-amz-meta-surrogate-control
header on the copied files. TheSurrogate-Control
orx-amz-meta-surrogate-control
header is used in priority by Fastly to givern it’s caching. This caching policy is not passed to the browser.create_directory_redirect_object (
bool
, optional) – Create a directory redirect object for the root directory. The directory redirect object is an empty S3 object named after the directory (without a trailing slash) that contains ax-amz-meta-dir-redirect=true
HTTP header. LSST the Docs’ Fastly VCL is configured to redirect requests for a directory path to the directory’sindex.html
(known as courtesy redirects).
- Raises:
ltdconveyor.s3.S3Error – Thrown by any unexpected faults from the S3 API.
RuntimeError – Thrown when the source and destination directories are the same.
- Return type: