Use app×
QUIZARD
QUIZARD
JEE MAIN 2026 Crash Course
NEET 2026 Crash Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
+1 vote
91 views
in Information Technology by (178k points)
How can you change the storage class of an existing object in S3?

Please log in or register to answer this question.

1 Answer

+1 vote
by (178k points)

You can change the storage class of an existing object in S3 by copying the object to the same bucket with a different storage class. Here's an example using Boto3:

import boto3

# Create an S3 client
s3 = boto3.client('s3')

# Define the bucket name and object key
bucket_name = 'your-bucket-name'
object_key = 'your-object-key'
new_storage_class = 'GLACIER'  # Example: S3 Glacier

# Copy the object to itself with a new storage class
copy_source = {'Bucket': bucket_name, 'Key': object_key}
s3.copy_object(
    CopySource=copy_source,
    Bucket=bucket_name,
    Key=object_key,
    StorageClass=new_storage_class
)

print(f'Object {object_key} in bucket {bucket_name} has been changed to storage class {new_storage_class}')

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...