### List Buckets using Python (Boto3) Source: https://www.idrive.com/s3-storage-e2/guides/list_buckets This Python code snippet uses the Boto3 library to connect to IDrive® e2 and list all available buckets. It requires the 'boto3' library to be installed and the storage endpoint to be configured. ```python #!/bin/python import boto3 # Create an S3 client for IDrive e2 endpoint = "l4g4.ch11.idrivee2-2.com" client = boto3.client("s3", endpoint_url=endpoint) # Get list of buckets response = client.list_buckets() # print bucket names for bucket in response["Buckets"]: print(bucket["Name"]) ``` -------------------------------- ### List Buckets using Node.js (AWS SDK) Source: https://www.idrive.com/s3-storage-e2/guides/list_buckets This Node.js example demonstrates how to list buckets in IDrive® e2 storage using the AWS SDK. It requires the 'aws-sdk' package and your access key and secret key to be set as environment variables. ```javascript const AWS = require('aws-sdk'); // Create an S3 client for IDrive e2 const s3 = new AWS.S3({ endpoint: "https://xyz1.ch11.idrivee2-2.com", //your storage-endpoint accessKeyId: process.env.access_key, //your access-key secretAccessKey: process.env.secret_key, //your secret-key }); // list buckets call s3.listBuckets(function(err, data) { if (err) { console.log("Error:", err); } else { console.log("Success:", data); } }); ``` -------------------------------- ### Create Bucket using Node.js (AWS SDK) Source: https://www.idrive.com/s3-storage-e2/guides/create_bucket This Node.js example demonstrates creating a bucket named 'my-bucket' for IDrive® e2 using the AWS SDK. It requires the 'aws-sdk' package and environment variables for access and secret keys. ```javascript const AWS = require('aws-sdk'); // Create an S3 client for IDrive e2 const s3 = new AWS.S3({ endpoint: "https://xyz1.ch11.idrivee2-2.com", //your storage-endpoint accessKeyId: process.env.access_key, //your access-key secretAccessKey: process.env.secret_key, //your secret-key }); // create bucket 'my-bucket' params var params = { Bucket: "my-bucket", }; // create bucket call s3.createBucket(params, function(err, data) { if (err) { console.log("Error:", err); } else { console.log("Success:", data); } }); ``` -------------------------------- ### Create Bucket using Python (Boto3) Source: https://www.idrive.com/s3-storage-e2/guides/create_bucket This Python script utilizes the Boto3 library to create a bucket named 'my-bucket' within IDrive® e2. It requires the 'boto3' library to be installed and configured with your storage endpoint. ```python #!/bin/python import boto3 # Create an S3 client for IDrive e2 endpoint = "l4g4.ch11.idrivee2-2.com" client = boto3.client("s3", endpoint_url=endpoint) # create bucket 'my-bucket' client.create_bucket(Bucket="my-bucket") ``` -------------------------------- ### Delete Bucket using Node.js (AWS SDK) Source: https://www.idrive.com/s3-storage-e2/guides/delete_bucket This Node.js example demonstrates how to delete a bucket using the AWS SDK. It requires setting up the S3 client with your IDrive® e2 storage endpoint, access key, and secret key. Ensure you have the 'aws-sdk' package installed. ```javascript const AWS = require('aws-sdk'); // Create an S3 client for IDrive e2 const s3 = new AWS.S3({ endpoint: "https://xyz1.ch11.idrivee2-2.com", //your storage-endpoint accessKeyId: process.env.access_key, //your access-key secretAccessKey: process.env.secret_key, //your secret-key }); // delete bucket 'my-bucket' params var params = { Bucket: "my-bucket", }; // delete bucket call s3.deleteBucket(params, function(err, data) { if (err) { console.log("Error:", err); } else { console.log("Success:", data); } }); ``` -------------------------------- ### Create Bucket using Ruby (AWS SDK) Source: https://www.idrive.com/s3-storage-e2/guides/create_bucket This Ruby code snippet demonstrates creating a bucket named 'my-bucket' for IDrive® e2 storage. It requires the 'aws-sdk-s3' gem and proper configuration of your endpoint and region. ```ruby require 'aws-sdk-s3' # Create an S3 client for IDrive e2 endpoint = 'l4g4.ch11.idrivee2-2.com' client = Aws::S3::Client.new(region: 'Chicago', endpoint: endpoint) # create bucket 'my-bucket' begin puts "Success: #{client.create_bucket(bucket: 'my-bucket')}" rescue StandardError => ex puts "Error: #{ex}" end ``` -------------------------------- ### AWS CLI Configuration for IDrive e2 Source: https://www.idrive.com/s3-storage-e2/guides/operations Provides sample configuration parameters for the AWS CLI, including region and credentials, to interact with IDrive® e2 storage. Users need to specify the correct endpoint URL. ```bash [default] region = us-east-1 ``` ```bash [default] aws_access_key_id = aws_secret_access_key = ``` -------------------------------- ### List Objects in Bucket (AWS CLI) Source: https://www.idrive.com/s3-storage-e2/guides/list_objects This AWS CLI command lists all objects within a specified bucket. It requires the bucket name and the S3 endpoint URL. ```AWS CLI aws s3 ls s3://my-bucket --endpoint-url https://storageendpoint ``` -------------------------------- ### List Buckets using AWS CLI Source: https://www.idrive.com/s3-storage-e2/guides/list_buckets This command lists all buckets in your IDrive® e2 storage using the AWS Command Line Interface. Ensure you have configured the AWS CLI with your endpoint. ```bash aws s3api list-buckets --endpoint-url https://storageendpoint ``` -------------------------------- ### List Buckets using Ruby (AWS SDK) Source: https://www.idrive.com/s3-storage-e2/guides/list_buckets This Ruby code demonstrates how to list buckets in IDrive® e2 storage using the AWS SDK for Ruby. It requires the 'aws-sdk-s3' gem and proper initialization of the S3 client with the correct endpoint. ```ruby require 'aws-sdk-s3' # Create an S3 client for IDrive e2 endpoint = 'l4g4.ch11.idrivee2-2.com' client = Aws::S3::Client.new(region: 'Chicago', endpoint: endpoint) # List buckets call begin puts "Success: #{client.list_buckets}" rescue StandardError => ex puts "Error: #{ex}" end ``` -------------------------------- ### Delete Bucket using Python (Boto3) Source: https://www.idrive.com/s3-storage-e2/guides/delete_bucket This Python script uses the Boto3 library to delete a bucket from IDrive® e2 storage. It requires the 'boto3' library to be installed and configured with your storage endpoint. ```python #!/bin/python import boto3 # Create an S3 client for IDrive e2 endpoint = "l4g4.ch11.idrivee2-2.com" client = boto3.client("s3", endpoint_url=endpoint) # delete bucket 'my-bucket' client.delete_bucket(Bucket="my-bucket") ``` -------------------------------- ### Retrieve Object Metadata using Ruby (AWS SDK) Source: https://www.idrive.com/s3-storage-e2/guides/list_object_metadata This Ruby code example shows how to get object metadata from IDrive e2. It initializes an S3 client with the specified endpoint and handles potential errors during the operation. ```ruby require 'aws-sdk-s3' # Create an S3 client for IDrive e2 endpoint = 'l4g4.ch11.idrivee2-2.com' client = Aws::S3::Client.new(region: 'Chicago', endpoint: endpoint) # head 'my-object' in bucket 'my-bucket' begin puts "Success: #{client.head_object(bucket: 'my-bucket', key: 'my-object')}" rescue StandardError => ex puts "Error: #{ex}" end ``` -------------------------------- ### Create Bucket using AWS CLI Source: https://www.idrive.com/s3-storage-e2/guides/create_bucket This command uses the AWS CLI to create a new bucket named 'my-bucket' for IDrive® e2 storage. Ensure you have the AWS CLI configured with your IDrive® e2 credentials and endpoint. ```bash aws s3 mb s3://my-bucket --endpoint-url https://storageendpoint ``` -------------------------------- ### List Buckets using PHP (AWS SDK) Source: https://www.idrive.com/s3-storage-e2/guides/list_buckets This PHP code snippet shows how to list buckets in IDrive® e2 storage using the AWS SDK for PHP. It utilizes Composer for dependency management and requires proper configuration of the S3 client. ```php "default", "endpoint" => "l4g4.ch11.idrivee2-2.com", "region" => "Chicago", "version" => "latest", "use_path_style_endpoint" => true, ]; $s3 = S3Client::factory($profile_credentials); // Get list of buckets try { $buckets = $s3->listBuckets(); // print bucket names foreach ($buckets["Buckets"] as $bucket) { echo "{$bucket["Name"]}\n"; } } catch (AwsException $e) { echo "Error: {$e->getMessage()}" . PHP_EOL; } ``` -------------------------------- ### List Objects Recursively (AWS CLI) Source: https://www.idrive.com/s3-storage-e2/guides/list_objects This AWS CLI command lists all objects within a specified bucket recursively. It requires the bucket name, the --recursive flag, and the S3 endpoint URL. ```AWS CLI aws s3 ls s3://my-bucket --recursive --endpoint-url https://storageendpoint ``` -------------------------------- ### Create Bucket using PHP (AWS SDK) Source: https://www.idrive.com/s3-storage-e2/guides/create_bucket This PHP script shows how to create a bucket named 'my-bucket' in IDrive® e2 using the AWS SDK for PHP. It assumes you are using Composer for dependency management and have configured your credentials. ```php "default", "endpoint" => "l4g4.ch11.idrivee2-2.com", "region" => "Chicago", "version" => "latest", "use_path_style_endpoint" => true, ]; $s3 = S3Client::factory($profile_credentials); // create bucket 'my-bucket' try { $result = $s3->createBucket([ "Bucket" => "my-bucket", ]); echo "Success: "; var_dump($result["@metadata"]); } catch (AwsException $e) { echo "Error: {$e->getMessage()}" . PHP_EOL; } ``` -------------------------------- ### List Bucket Metadata using PHP (AWS SDK) Source: https://www.idrive.com/s3-storage-e2/guides/list_bucket_metadata This PHP script demonstrates how to retrieve bucket metadata using the AWS SDK for PHP. It includes setup for Composer and handling potential AWS exceptions. ```PHP "default", "endpoint" => "l4g4.ch11.idrivee2-2.com", "region" => "Chicago", "version" => "latest", "use_path_style_endpoint" => true, ]; $s3 = S3Client::factory($profile_credentials); // head bucket 'my-bucket' try { $result = $s3->headBucket([ "Bucket" => "my-bucket", ]); echo "Success: "; var_dump($result["@metadata"]); } catch (AwsException $e) { echo "Error: {$e->getMessage()}" . PHP_EOL; } ``` -------------------------------- ### Enable Versioning for IDrive S3 Bucket (PHP) Source: https://www.idrive.com/s3-storage-e2/guides/bucket_versioning Enables versioning for a specified IDrive S3 bucket using the AWS SDK for PHP. Requires Composer for installation. ```PHP "default", "endpoint" => "l4g4.ch11.idrivee2-2.com", "region" => "Chicago", "version" => "latest", "use_path_style_endpoint" => true, ]; $s3 = S3Client::factory($profile_credentials); $bucket = "my-bucket"; // Enable versioning for bucket $params = [ "Bucket" => $bucket, "VersioningConfiguration" => [ "Status" => "Enabled", ], ]; try { $result = $s3->putBucketVersioning($params); echo "Success: "; var_dump($result); } catch (AwsException $e) { echo "Error: {$e->getMessage()}" . PHP_EOL; } ``` -------------------------------- ### Upload Object using PHP (AWS SDK) Source: https://www.idrive.com/s3-storage-e2/guides/create_objects Uploads a local file to an IDrive® e2 bucket using the PHP AWS SDK. This example demonstrates setting up the S3 client with specific credentials and endpoint, and then using the putObject method with SourceFile. ```php "default", "endpoint" => "l4g4.ch11.idrivee2-2.com", "region" => "Chicago", "version" => "latest", "use_path_style_endpoint" => true, ]; $s3 = S3Client::factory($profile_credentials); $bucket = "my-bucket"; $key = "my-object"; $file_path = "local-object"; // upload object 'local-object' in bucket 'my-bucket' as 'my-object' try { $result = $s3->putObject([ "Bucket" => $bucket, "Key" => $key, "SourceFile" => $file_path, ]); echo "Success: "; var_dump($result["@metadata"]); } catch (AwsException $e) { echo "Error: {$e->getMessage()}" . PHP_EOL; } ``` -------------------------------- ### Delete Object using Node.js (AWS SDK) Source: https://www.idrive.com/s3-storage-e2/guides/delete_object This Node.js example demonstrates how to delete an object from an IDrive e2 bucket using the AWS SDK. It requires the 'aws-sdk' package and your access key ID and secret access key to be set as environment variables. ```javascript const AWS = require('aws-sdk'); // Create an S3 client for IDrive e2 const s3 = new AWS.S3({ endpoint: "https://xyz1.ch11.idrivee2-2.com", //your storage-endpoint accessKeyId: process.env.access_key, //your access-key secretAccessKey: process.env.secret_key, //your secret-key }); // delete object 'my-object' in bucket 'my-bucket' params var params = { Bucket: "my-bucket", Key: "my-object" }; // delete object call s3.deleteObject(params, function(err, data) { if (err) { console.log("Error:", err); } else { console.log("Success:", data); } }); ``` -------------------------------- ### List Object Versions for IDrive S3 Bucket (PHP) Source: https://www.idrive.com/s3-storage-e2/guides/bucket_versioning Lists all versions of all objects within a specified IDrive S3 bucket using the AWS SDK for PHP. Requires Composer for installation. ```PHP "default", "endpoint" => "l4g4.ch11.idrivee2-2.com", "region" => "Chicago", "version" => "latest", "use_path_style_endpoint" => true, ]; $s3 = S3Client::factory($profile_credentials); $bucket = "my-bucket"; // List Object Versions for bucket try { $result = $s3->listObjectVersions([ "Bucket" => $bucket, ]); echo "Success: "; var_dump($result); } catch (AwsException $e) { echo "Error: {$e->getMessage()}" . PHP_EOL; } ``` -------------------------------- ### Delete Multiple Objects using PHP Source: https://www.idrive.com/s3-storage-e2/guides/delete_multiple_objects This PHP example demonstrates deleting multiple objects from an IDrive e2 bucket using the AWS SDK for PHP. It utilizes Composer for dependency management. The code initializes an S3 client with specific endpoint and credentials, then calls the `deleteObjects` method with a list of object keys to be removed. ```php "default", "endpoint" => "l4g4.ch11.idrivee2-2.com", "region" => "Chicago", "version" => "latest", "use_path_style_endpoint" => true, ]; $s3 = S3Client::factory($profile_credentials); // delete objects with key 'object1', 'object2' and 'object3' in bucket 'my-bucket' params $params = [ "Bucket" => "my-bucket", "Delete" => [ "Objects" => [ [ "Key" => "object1", ], [ "Key" => "object2", ], [ "Key" => "object3", ], ], "Quiet" => false, ], ]; // delete objects call try { $result = $s3->deleteObjects($params); echo "Success: "; var_dump($result); } catch (AwsException $e) { echo "Error: {$e->getMessage()}" . PHP_EOL; } ``` -------------------------------- ### List Objects in Bucket (Python) Source: https://www.idrive.com/s3-storage-e2/guides/list_objects This Python code snippet uses the boto3 library to list objects in an IDrive e2 bucket. It requires configuring the S3 client with the endpoint URL and then calling the list_objects method. ```Python #!/bin/python import boto3 # Create an S3 client for IDrive e2 endpoint = "l4g4.ch11.idrivee2-2.com" client = boto3.client("s3", endpoint_url=endpoint) # Get list of objects in bucket 'my-bucket' print(client.list_objects(Bucket="my-bucket")) ``` -------------------------------- ### List Bucket Metadata using Node.js (AWS SDK) Source: https://www.idrive.com/s3-storage-e2/guides/list_bucket_metadata This Node.js example utilizes the AWS SDK to fetch bucket metadata from IDrive e2. It requires configuring the S3 client with the storage endpoint, access key, and secret key. ```JavaScript const AWS = require('aws-sdk'); // Create an S3 client for IDrive e2 const s3 = new AWS.S3({ endpoint: "https://xyz1.ch11.idrivee2-2.com", //your storage-endpoint accessKeyId: process.env.access_key, //your access-key secretAccessKey: process.env.secret_key, //your secret-key }); // bucket params var params = { Bucket: "my-bucket", }; // head bucket with the above params s3.headBucket(params, function(err, data) { if (err) { console.log("Error:", err); } else { console.log("Success:", data); } }); ``` -------------------------------- ### List Objects in Bucket (Ruby) Source: https://www.idrive.com/s3-storage-e2/guides/list_objects This Ruby code snippet uses the aws-sdk-s3 gem to list objects in an IDrive e2 bucket. It requires creating an S3 client with the endpoint and region, then calling the list_objects method. ```Ruby require 'aws-sdk-s3' # Create an S3 client for IDrive e2 endpoint = 'l4g4.ch11.idrivee2-2.com' client = Aws::S3::Client.new(region: 'Chicago', endpoint: endpoint) # Get list of objects in bucket 'my-bucket' begin puts "Success: #{client.list_objects(bucket: 'my-bucket')}" rescue StandardError => ex puts "Error: #{ex}" end ``` -------------------------------- ### List Bucket Metadata using Ruby (AWS SDK) Source: https://www.idrive.com/s3-storage-e2/guides/list_bucket_metadata This Ruby code snippet shows how to get bucket metadata from IDrive e2 storage. It initializes the S3 client with the specified endpoint and region. ```Ruby require 'aws-sdk-s3' # Create an S3 client for IDrive e2 endpoint = 'l4g4.ch11.idrivee2-2.com' client = Aws::S3::Client.new(region: 'Chicago', endpoint: endpoint) # head bucket 'my-bucket' begin puts "Success: #{client.head_bucket(bucket: 'my-bucket')}" rescue StandardError => ex puts "Error: #{ex}" end ``` -------------------------------- ### List Objects in Bucket (PHP) Source: https://www.idrive.com/s3-storage-e2/guides/list_objects This PHP code snippet uses the AWS SDK for PHP to list objects in an IDrive e2 bucket. It requires setting up the S3 client with profile credentials, endpoint, region, and version, then calling the listObjects method. ```PHP "default", "endpoint" => "l4g4.ch11.idrivee2-2.com", "region" => "Chicago", "version" => "latest", "use_path_style_endpoint" => true, ]; $s3 = S3Client::factory($profile_credentials); // list objects in bucket 'my-bucket' try { $result = $s3->listObjects([ "Bucket" => "my-bucket", ]); echo "Success: "; var_dump($result["Contents"]); } catch (AwsException $e) { echo "Error: {$e->getMessage()}" . PHP_EOL; } ``` -------------------------------- ### Upload Object using Node.js (AWS SDK) Source: https://www.idrive.com/s3-storage-e2/guides/create_objects Uploads a local file to an IDrive® e2 bucket using the Node.js AWS SDK. This example shows how to create a readable stream for the file, configure the S3 client with endpoint and credentials, and use the putObject method. ```javascript const AWS = require('aws-sdk'); const PATH = require('path'); const FS = require('fs'); // Full path of object. For example '../files/local-object' const file = "local-object"; const fileStream = new FS.createReadStream(file); // Create an S3 client for IDrive e2 const s3 = new AWS.S3({ endpoint: "https://xyz1.ch11.idrivee2-2.com", //your storage-endpoint accessKeyId: process.env.access_key, //your access-key secretAccessKey: process.env.secret_key, //your secret-key }); // upload object 'local-object' as 'my-object' in bucket 'my-bucket' params var params = { Bucket: "my-bucket", Key: "my-object", Body: fileStream }; // put object call s3.putObject(params, function(err, data) { if (err) { console.log("Error:", err); } else { console.log("Success:", data); } }); ``` -------------------------------- ### Retrieve Object Metadata using Node.js (AWS SDK) Source: https://www.idrive.com/s3-storage-e2/guides/list_object_metadata This Node.js example utilizes the AWS SDK to fetch object metadata from IDrive e2. It requires configuring the S3 client with the storage endpoint, access key, and secret key. ```javascript const AWS = require('aws-sdk'); // Create an S3 client for IDrive e2 const s3 = new AWS.S3({ endpoint: "https://xyz1.ch11.idrivee2-2.com", //your storage-endpoint accessKeyId: process.env.access_key, //your access-key secretAccessKey: process.env.secret_key, //your secret-key }); // head 'my-object' in bucket 'my-bucket' params var params = { Bucket: "my-bucket", Key: "my-object" }; // head object call s3.headObject(params, function(err, data) { if (err) { console.log("Error:", err); } else { console.log("Success:", data); } }); ``` -------------------------------- ### List Objects in Bucket (Node.js) Source: https://www.idrive.com/s3-storage-e2/guides/list_objects This Node.js code snippet uses the AWS SDK to list objects in an IDrive e2 bucket. It requires configuring the S3 client with the endpoint, access key ID, and secret access key, then calling the listObjects method. ```Node.js const AWS = require('aws-sdk'); // Create an S3 client for IDrive e2 const s3 = new AWS.S3({ endpoint: "https://xyz1.ch11.idrivee2-2.com", //your storage-endpoint accessKeyId: process.env.access_key, //your access-key secretAccessKey: process.env.secret_key, //your secret-key }); // list of objects in bucket 'my-bucket' params var params = { Bucket: "my-bucket", }; // list object call s3.listObjects(params, function(err, data) { if (err) { console.log("Error:", err); } else { console.log("Success:", data); } }); ``` -------------------------------- ### Copy Object using Node.js (AWS SDK) Source: https://www.idrive.com/s3-storage-e2/guides/copy_object This Node.js example utilizes the AWS SDK to copy an object. It requires setting the endpoint, access key ID, and secret access key for your IDrive e2 storage. The `copyObject` method is used with parameters specifying the source and destination. ```javascript const AWS = require('aws-sdk'); // Create an S3 client for IDrive e2 const s3 = new AWS.S3({ endpoint: "https://xyz1.ch11.idrivee2-2.com", //your storage-endpoint accessKeyId: process.env.access_key, //your access-key secretAccessKey: process.env.secret_key, //your secret-key }); // copy object 'my-object' in bucket 'my-bucket' to bucket 'my-new-bucket' as 'my-object' params var params = { Bucket: "my-new-bucket", CopySource: "/my-bucket/my-object", Key: "my-object" }; // copy object call s3.copyObject(params, function(err, data) { if (err) { console.log("Error:", err); } else { console.log("Success:", data); } }); ``` -------------------------------- ### Delete Bucket using Ruby (AWS SDK) Source: https://www.idrive.com/s3-storage-e2/guides/delete_bucket This Ruby script shows how to delete a bucket from IDrive® e2 storage using the AWS SDK for Ruby. It initializes the S3 client with the specified endpoint and then calls the delete_bucket method. Error handling is included for the operation. ```ruby require 'aws-sdk-s3' # Create an S3 client for IDrive e2 endpoint = 'l4g4.ch11.idrivee2-2.com' client = Aws::S3::Client.new(region: 'Chicago', endpoint: endpoint) # delete bucket 'my-bucket' begin puts "Success: #{client.delete_bucket(bucket: 'my-bucket')}" rescue StandardError => ex puts "Error: #{ex}" end ``` -------------------------------- ### Delete Object using Python (Boto3) Source: https://www.idrive.com/s3-storage-e2/guides/delete_object This Python code uses the Boto3 library to delete an object from an IDrive e2 bucket. It requires the 'boto3' library to be installed and configured with your storage endpoint. ```python #!/bin/python import boto3 # Create an S3 client for IDrive e2 endpoint = "l4g4.ch11.idrivee2-2.com" client = boto3.client("s3", endpoint_url=endpoint) # delete object 'my-object' in bucket 'my-bucket' client.delete_object(Bucket="my-bucket", Key="my-object") ``` -------------------------------- ### Set Page Title with jQuery Source: https://www.idrive.com/s3-storage-e2/guides/default This snippet demonstrates how to dynamically set the page title using jQuery. It selects the document's attribute 'title' and assigns a new string value to it. ```javascript jQuery(document).attr("title", "Welcome to Sterling Kilgore | Results Beyond Words"); ``` -------------------------------- ### Generate Pre-signed URL with jQuery Source: https://www.idrive.com/s3-storage-e2/guides/pre_signed_url This snippet demonstrates how to set the title of the current page using jQuery, which is often a precursor to interacting with web services or APIs. It's a client-side JavaScript example. ```javascript jQuery(document).attr("title", "Welcome to Sterling Kilgore | Results Beyond Words"); ``` -------------------------------- ### JavaScript Example for Setting Page Title Source: https://www.idrive.com/s3-storage-e2/guides/get_region_endpoint A simple JavaScript snippet using jQuery to set the document's title. This is often used for dynamic page title updates in web applications. ```JavaScript jQuery(document).attr("title", "Welcome to Sterling Kilgore | Results Beyond Words"); ``` -------------------------------- ### Manage Bucket Versioning (Python) Source: https://www.idrive.com/s3-storage-e2/guides/bucket_versioning Demonstrates how to manage bucket versioning (enable, check status, list versions) for IDrive e2 using the Python SDK (boto3). Requires bucket name, object prefix, and endpoint URL. ```Python #!/bin/python import boto3 # Create an S3 client for IDrive e2 endpoint = "l4g4.ch11.idrivee2-2.com" client = boto3.client("s3", endpoint_url=endpoint) # enable versioning for bucket 'my-bucket' client.put_bucket_versioning( Bucket="my-bucket", VersioningConfiguration={"Status": "Enabled"} ) # check bucket versioning status print(client.get_bucket_versioning(Bucket="my-bucket")["Status"]) # list all versions of all objects present in bucket 'my-bucket' response = client.list_object_versions(Bucket="my-bucket") print(response) # list all versions of 'my-object' prefix(key/object name) object present in bucket 'my-bucket' response = client.list_object_versions(Bucket="my-bucket", Prefix="my-object") print(response) ``` -------------------------------- ### Upload Object using AWS CLI Source: https://www.idrive.com/s3-storage-e2/guides/create_objects Uploads a local file to an IDrive® e2 bucket using the AWS Command Line Interface. This command specifies the source file, destination object name, bucket name, and the S3 endpoint URL. ```bash aws s3 cp local-object s3://my-bucket/my-object --endpoint-url https://storageendpoint ``` -------------------------------- ### Delete Object using PHP (AWS SDK) Source: https://www.idrive.com/s3-storage-e2/guides/delete_object This PHP code snippet shows how to delete an object from an IDrive e2 bucket using the AWS SDK for PHP. It utilizes the Composer installation method and requires proper configuration of credentials and endpoint. ```php "default", "endpoint" => "l4g4.ch11.idrivee2-2.com", "region" => "Chicago", "version" => "latest", "use_path_style_endpoint" => true, ]; $s3 = S3Client::factory($profile_credentials); // delete object 'my-object' in bucket 'my-bucket' try { $result = $s3->deleteObject([ "Bucket" => "my-bucket", "Key" => "my-object", ]); echo "Success: "; var_dump($result["@metadata"]); } catch (AwsException $e) { echo "Error: {$e->getMessage()}" . PHP_EOL; } ``` -------------------------------- ### Delete Bucket using PHP (AWS SDK) Source: https://www.idrive.com/s3-storage-e2/guides/delete_bucket This PHP script utilizes the AWS SDK for PHP to delete a bucket from IDrive® e2 storage. It assumes you have installed the SDK via Composer. The code includes error handling for the delete operation. ```php "default", "endpoint" => "l4g4.ch11.idrivee2-2.com", "region" => "Chicago", "version" => "latest", "use_path_style_endpoint" => true, ]; $s3 = S3Client::factory($profile_credentials); // delete bucket 'my-bucket' try { $result = $s3->deleteBucket([ "Bucket" => "my-bucket", ]); echo "Success: "; var_dump($result["@metadata"]); } catch (AwsException $e) { echo "Error: {$e->getMessage()}" . PHP_EOL; } ``` -------------------------------- ### Delete Multiple Objects using Ruby Source: https://www.idrive.com/s3-storage-e2/guides/delete_multiple_objects This Ruby example shows how to delete multiple objects from an IDrive e2 bucket. It requires the 'aws-sdk-s3' gem. The code initializes an S3 client with the specified endpoint and region, then uses the `delete_objects` method to remove a list of objects identified by their keys from the target bucket. ```ruby require 'aws-sdk-s3' # Create an S3 client for IDrive e2 endpoint = 'l4g4.ch11.idrivee2-2.com' client = Aws::S3::Client.new(region: 'Chicago', endpoint: endpoint) # delete multiple objects with key 'object1', 'object2' and 'object3' in bucket 'my-bucket' begin response = client.delete_objects( bucket: 'my-bucket', delete: { objects: [ { key: 'object1' }, { key: 'object2' }, { key: 'object3' } ], quiet: false } ) puts "Success: #{response}" rescue StandardError => ex puts "Error: #{ex}" end ``` -------------------------------- ### Copy Object using Python (Boto3) Source: https://www.idrive.com/s3-storage-e2/guides/copy_object This Python script uses the Boto3 library to copy an object. It requires the 's3' client to be initialized with the IDrive e2 endpoint. The `copy_object` method takes the source bucket and key, and the destination bucket and key. ```python import boto3 # Create an S3 client for IDrive e2 endpoint = "l4g4.ch11.idrivee2-2.com" client = boto3.client("s3", endpoint_url=endpoint) # copy object 'my-object' in bucket 'my-bucket' to bucket 'my-new-bucket' as 'my-object' client.copy_object( CopySource={"Bucket": "my-bucket", "Key": "my-object"}, Bucket="my-new-bucket", Key="my-object", ) ``` -------------------------------- ### Delete Multiple Objects using Node.js Source: https://www.idrive.com/s3-storage-e2/guides/delete_multiple_objects This Node.js example shows how to delete multiple objects from an IDrive e2 bucket using the AWS SDK. It requires the 'aws-sdk' package and configuration of the S3 client with your storage endpoint, access key, and secret key. The `deleteObjects` method is used with a `Delete` object containing a list of keys to remove. ```javascript const AWS = require('aws-sdk'); // Create an S3 client for IDrive e2 const s3 = new AWS.S3({ endpoint: "https://xyz1.ch11.idrivee2-2.com", //your storage-endpoint accessKeyId: process.env.access_key, //your access-key secretAccessKey: process.env.secret_key, //your secret-key }); // delete objects with key 'object1', 'object2' and 'object3' in bucket 'my-bucket' params var params = { Bucket: "my-bucket", Delete: { Objects: [{ Key: "object1" }, { Key: "object2" }, { Key: "object3" } ], Quiet: false } }; // delete objects call s3.deleteObjects(params, function(err, data) { if (err) { console.log("Error:", err); } else { console.log("Success:", data); } }); ``` -------------------------------- ### Get Region Endpoint API Request Source: https://www.idrive.com/s3-storage-e2/guides/get_region_endpoint This snippet demonstrates how to call the IDrive E2 API to get the user's region endpoint. It includes the method, URL, content type, and the required JSON body with an access key. ```HTTP POST /api/service/get_region_end_point HTTP/1.1 Host: api.idrivee2.com Content-Type: application/json { "access_key": "**ZGFsbGFza2V5L4IjxocC** " } ``` -------------------------------- ### Enable Versioning for IDrive S3 Bucket (JavaScript) Source: https://www.idrive.com/s3-storage-e2/guides/bucket_versioning Enables versioning for a specified IDrive S3 bucket using the AWS SDK for JavaScript. Requires 'aws-sdk' package. ```JavaScript const AWS = require('aws-sdk'); // Create an S3 client for IDrive e2 const s3 = new AWS.S3({ endpoint: "https://xyz1.ch11.idrivee2-2.com", //your storage-endpoint accessKeyId: process.env.access_key, //your access-key secretAccessKey: process.env.secret_key, //your secret-key }); // Enable versioning for bucket 'my-bucket' var params = { Bucket: "my-bucket", VersioningConfiguration: { Status: "Enabled" } }; s3.putBucketVersioning(params, function(err, data) { if (err) { console.log("Error:", err); } else { console.log("Success:", data); } }); ``` -------------------------------- ### List All Object Versions (AWS CLI) Source: https://www.idrive.com/s3-storage-e2/guides/bucket_versioning Lists all versions of all objects present in a specified bucket using the AWS CLI. Requires the bucket name and endpoint URL. ```AWS CLI aws s3api list-object-versions --bucket my-bucket --endpoint-url https://storageendpoint ``` -------------------------------- ### Set Page Title with jQuery Source: https://www.idrive.com/s3-storage-e2/guides/developer_guide This snippet demonstrates how to set the page title using jQuery. It selects the document's attribute 'title' and assigns a new string value. ```JavaScript jQuery(document).attr("title", "Welcome to Sterling Kilgore | Results Beyond Words"); ``` -------------------------------- ### Upload Object using Ruby (AWS SDK) Source: https://www.idrive.com/s3-storage-e2/guides/create_objects Uploads a local file to an IDrive® e2 bucket using the Ruby AWS SDK. It shows how to initialize an S3 client with the correct endpoint and then use the put_object method to upload the file. ```ruby require 'aws-sdk-s3' # Create an S3 client for IDrive e2 endpoint = 'l4g4.ch11.idrivee2-2.com' client = Aws::S3::Client.new(region: 'Chicago', endpoint: endpoint) # upload 'local-object'(full path of object) in bucket 'my-bucket' as 'my-object' begin file = File.open('local-object', 'rb') response = client.put_object( body: file, bucket: 'my-bucket', key: 'my-object' ) puts "Success: #{response}" rescue StandardError => ex puts "Error: #{ex}" end ``` -------------------------------- ### Disable Versioning for IDrive S3 Bucket (PHP) Source: https://www.idrive.com/s3-storage-e2/guides/bucket_versioning Disables versioning for a specified IDrive S3 bucket using the AWS SDK for PHP. Requires Composer for installation. ```PHP "default", "endpoint" => "l4g4.ch11.idrivee2-2.com", "region" => "Chicago", "version" => "latest", "use_path_style_endpoint" => true, ]; $s3 = S3Client::factory($profile_credentials); $bucket = "my-bucket"; // Disable versioning for bucket $params = [ "Bucket" => $bucket, "VersioningConfiguration" => [ "Status" => "Suspended", ], ]; try { $result = $s3->putBucketVersioning($params); echo "Success: "; var_dump($result); } catch (AwsException $e) { echo "Error: {$e->getMessage()}" . PHP_EOL; } ``` -------------------------------- ### Upload Object using Python (boto3) Source: https://www.idrive.com/s3-storage-e2/guides/create_objects Uploads a local file to an IDrive® e2 bucket using the Python boto3 library. It demonstrates creating an S3 client with a specified endpoint and then using the upload_file method to transfer the object. ```python #!/bin/python import boto3 # Create an S3 client for IDrive e2 endpoint = "l4g4.ch11.idrivee2-2.com" client = boto3.client("s3", endpoint_url=endpoint) # upload 'local-object'(full path of object) in bucket 'my-bucket' as 'my-object' client.upload_file("local-object", "my-bucket", "my-object") ``` -------------------------------- ### Set Page Title with jQuery Source: https://www.idrive.com/s3-storage-e2/guides/more_resources This snippet demonstrates how to use jQuery to dynamically set the page's title attribute. It's a common client-side manipulation technique. ```JavaScript jQuery(document).attr("title", "Welcome to Sterling Kilgore | Results Beyond Words"); ``` -------------------------------- ### Set Page Title with jQuery Source: https://www.idrive.com/s3-storage-e2/guides/basic_concepts This snippet demonstrates how to set the page title using jQuery. It selects the document's attribute 'title' and assigns a new string value to it. ```javascript jQuery(document).attr("title", "Welcome to Sterling Kilgore | Results Beyond Words"); ```