Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .doc_gen/metadata/s3_metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2952,6 +2952,14 @@ s3_Scenario_PresignedUrl:
- snippet_tags:
- s3.php.presigned_url.complete
- php.example_code.s3.service.S3Service
SAP ABAP:
versions:
- sdk_version: 1
github: sap-abap/services/s3
excerpts:
- description: Create presigned requests to GET S3 objects.
snippet_tags:
- s3.abapv1.s3_presigned_url_get
services:
s3: {}
s3_Scenario_ObjectVersioningUsage:
Expand Down
29 changes: 17 additions & 12 deletions cpp/example_code/s3/put_object_async.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ std::condition_variable AwsDoc::S3::upload_variable;
*/

// snippet-start:[s3.cpp.put_object_async_finished.code]
void putObjectAsyncFinished(const Aws::S3::S3Client *s3Client,
void uploadFileAsyncFinished(const Aws::S3::S3Client *s3Client,
const Aws::S3::Model::PutObjectRequest &request,
const Aws::S3::Model::PutObjectOutcome &outcome,
const std::shared_ptr<const Aws::Client::AsyncCallerContext> &context) {
if (outcome.IsSuccess()) {
std::cout << "Success: putObjectAsyncFinished: Finished uploading '"
std::cout << "Success: uploadFileAsyncFinished: Finished uploading '"
<< context->GetUUID() << "'." << std::endl;
} else {
std::cerr << "Error: putObjectAsyncFinished: " <<
std::cerr << "Error: uploadFileAsyncFinished: " <<
outcome.GetError().GetMessage() << std::endl;
}

Expand All @@ -68,17 +68,17 @@ void putObjectAsyncFinished(const Aws::S3::S3Client *s3Client,
//! Routine which demonstrates adding an object to an Amazon S3 bucket, asynchronously.
/*!
\param s3Client: Instance of the S3 Client.
\param request: Instance of the put object request.
\param bucketName: Name of the bucket.
\param fileName: Name of the file to put in the bucket.
\return bool: Function succeeded.
*/

// snippet-start:[s3.cpp.put_object_async.code]
bool AwsDoc::S3::putObjectAsync(const Aws::S3::S3Client &s3Client,
bool AwsDoc::S3::uploadFileAsync(const Aws::S3::S3Client &s3Client,
Aws::S3::Model::PutObjectRequest &request,
const Aws::String &bucketName,
const Aws::String &fileName) {
// Create and configure the asynchronous put object request.
Aws::S3::Model::PutObjectRequest request;
request.SetBucket(bucketName);
request.SetKey(fileName);

Expand All @@ -100,9 +100,9 @@ bool AwsDoc::S3::putObjectAsync(const Aws::S3::S3Client &s3Client,
context->SetUUID(fileName);

// Make the asynchronous put object call. Queue the request into a
// thread executor and call the putObjectAsyncFinished function when the
// thread executor and call the uploadFileAsyncFinished function when the
// operation has finished.
s3Client.PutObjectAsync(request, putObjectAsyncFinished, context);
s3Client.PutObjectAsync(request, uploadFileAsyncFinished, context);

return true;
}
Expand Down Expand Up @@ -135,7 +135,7 @@ int main(int argc, char* argv[])
return 1;
}

Aws::SDKOptions options;
const Aws::SDKOptions options;
Aws::InitAPI(options);
{
const Aws::String fileName = argv[1];
Expand All @@ -150,13 +150,18 @@ int main(int argc, char* argv[])
// Create and configure the Amazon S3 client.
// This client must be declared here, as this client must exist
// until the put object operation finishes.
Aws::S3::S3ClientConfiguration config;
const Aws::S3::S3ClientConfiguration config;
// Optional: Set to the AWS Region in which the bucket was created (overrides config file).
// config.region = "us-east-1";

Aws::S3::S3Client s3Client(config);
const Aws::S3::S3Client s3Client(config);

AwsDoc::S3::putObjectAsync(s3Client, bucketName, fileName);
// Create the request object.
// This request object must be declared here, because the object must exist
// until the put object operation finishes.
Aws::S3::Model::PutObjectRequest request;

AwsDoc::S3::uploadFileAsync(s3Client, request, bucketName, fileName);

std::cout << "main: Waiting for file upload attempt..." <<
std::endl << std::endl;
Expand Down
3 changes: 2 additions & 1 deletion cpp/example_code/s3/s3_examples.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ namespace AwsDoc {
const Aws::String &granteeID, const Aws::String &granteeEmailAddress,
const Aws::String &granteeURI, const Aws::S3::S3ClientConfiguration &clientConfig);

bool putObjectAsync(const Aws::S3::S3Client &s3Client,
bool uploadFileAsync(const Aws::S3::S3Client &s3Client,
Aws::S3::Model::PutObjectRequest &request,
const Aws::String &bucketName,
const Aws::String &fileName);

Expand Down
4 changes: 3 additions & 1 deletion cpp/example_code/s3/tests/gtest_put_object_async.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <gtest/gtest.h>
#include <fstream>
#include <aws/s3/S3Client.h>
#include <aws/s3/model/PutObjectRequest.h>
#include "../s3_examples.h"
#include "S3_GTests.h"

Expand All @@ -28,8 +29,9 @@ namespace AwsDocTest {

{
Aws::S3::S3Client client(*s_clientConfig);
Aws::S3::Model::PutObjectRequest request;
std::unique_lock<std::mutex> lock(AwsDoc::S3::upload_mutex);
bool result = AwsDoc::S3::putObjectAsync(client, bucketNames[0], testFile);
bool result = AwsDoc::S3::uploadFileAsync(client, request, bucketNames[0], testFile);

AwsDoc::S3::upload_variable.wait(lock);

Expand Down
2 changes: 1 addition & 1 deletion php/example_code/class_examples/CommandPool.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

$s3Service = new S3Service($client, true);

$bucket = 'my-bucket-' . uniqid(); // This bucket will be deleted at the end of this example.
$bucket = 'amzn-s3-demo-bucket-' . uniqid(); // This bucket will be deleted at the end of this example.

$client->createBucket([
"Bucket" => $bucket,
Expand Down
2 changes: 1 addition & 1 deletion php/example_code/cloudfront/CreateDistributionS3.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function createS3Distribution($cloudFrontClient, $distribution)
function createsTheS3Distribution()
{
$originName = 'my-unique-origin-name';
$s3BucketURL = 'my-bucket-name.s3.amazonaws.com';
$s3BucketURL = 'amzn-s3-demo-bucket.s3.amazonaws.com';
$callerReference = 'my-unique-caller-reference';
$comment = 'my-comment-about-this-distribution';
$defaultCacheBehavior = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function testCreatesAnS3Distribution()
require(__DIR__ . '/../CreateDistributionS3.php');

$originName = 'my-unique-origin-name';
$s3BucketURL = 'my-bucket-name.s3.amazonaws.com';
$s3BucketURL = 'amzn-s3-demo-bucket.s3.amazonaws.com';
$callerReference = 'my-unique-caller-reference';
$comment = 'my-comment-about-this-distribution';
$defaultCacheBehavior = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ protected function setUp(): void
'Origins' => [
'Items' => [
[
'DomainName' => 'my-bucket-name.s3.amazonaws.com',
'DomainName' => 'amzn-s3-demo-bucket.s3.amazonaws.com',
'Id' => 'my-unique-origin-name',
'OriginPath' => '',
'CustomHeaders' => [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ protected function setUp(): void
'Origins' => [
'Items' => [
[
'DomainName' => 'my-bucket-name.s3.amazonaws.com',
'DomainName' => 'amzn-s3-demo-bucket.s3.amazonaws.com',
'Id' => 'my-unique-origin-name',
'OriginPath' => '',
'CustomHeaders' => [
Expand Down
2 changes: 1 addition & 1 deletion php/example_code/cloudwatch/DescribeAlarmsForMetric.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ function describeTheAlarmsForMetric()
],
[
'Name' => 'BucketName',
'Value' => 'my-bucket'
'Value' => 'amzn-s3-demo-bucket'
]
];

Expand Down
2 changes: 1 addition & 1 deletion php/example_code/cloudwatch/GetMetricStatistics.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ function getTheMetricStatistics()
],
[
'Name' => 'BucketName',
'Value' => 'my-bucket'
'Value' => 'amzn-s3-demo-bucket'
]
];
$startTime = strtotime('-3 days');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function testDescribesAlarmsForAMetric()
],
[
'Name' => 'BucketName',
'Value' => 'my-bucket'
'Value' => 'amzn-s3-demo-bucket'
]
];

Expand Down
2 changes: 1 addition & 1 deletion php/example_code/lambda/GettingStartedWithLambda.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function run()
echo "Attached the AWSLambdaBasicExecutionRole to {$role['RoleName']}.\n";

echo "\nNow let's create an S3 bucket and upload our Lambda code there.\n";
$bucketName = "test-example-bucket-$uniqid";
$bucketName = "amzn-s3-demo-bucket-$uniqid";
$s3client->createBucket([
'Bucket' => $bucketName,
]);
Expand Down
2 changes: 1 addition & 1 deletion php/example_code/lambda/tests/LambdaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function testSingleActionCalls()
}
]
}";
$bucketName = "test-example-bucket-$uniqid";
$bucketName = "amzn-s3-demo-bucket-$uniqid";
$this->s3client->createBucket([
'Bucket' => $bucketName,
]);
Expand Down
2 changes: 1 addition & 1 deletion php/example_code/s3/CreateBucket.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function createTheBucket()
'version' => '2006-03-01'
]);

echo createBucket($s3Client, 'my-bucket');
echo createBucket($s3Client, 'amzn-s3-demo-bucket');
}

// Uncomment the following line to run this code in an AWS account.
Expand Down
4 changes: 2 additions & 2 deletions php/example_code/s3/ErrorHandling.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
$s3Client = $sdk->createS3();

try {
$s3Client->createBucket(['Bucket' => 'my-bucket']);
$s3Client->createBucket(['Bucket' => 'amzn-s3-demo-bucket']);
} catch (S3Exception $e) {
// Catch an S3 specific exception.
echo $e->getMessage();
Expand All @@ -53,7 +53,7 @@
// snippet-start:[s3.php.error_handling.async]
//Asynchronous Error Handling
// snippet-start:[s3.php.error_handling.promise]
$promise = $s3Client->createBucketAsync(['Bucket' => 'my-bucket']);
$promise = $s3Client->createBucketAsync(['Bucket' => 'amzn-s3-demo-bucket']);
// snippet-end:[s3.php.error_handling.promise]
$promise->otherwise(function ($reason) {
var_dump($reason);
Expand Down
4 changes: 2 additions & 2 deletions php/example_code/s3/PutObjectServiceOperations.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@

// Send a PutObject request and get the result object.
$result = $s3Client->putObject([
'Bucket' => 'my-bucket',
'Bucket' => 'amzn-s3-demo-bucket',
'Key' => 'my-key',
'Body' => 'this is the body!'
]);

// Download the contents of the object.
$result = $s3Client->getObject([
'Bucket' => 'my-bucket',
'Bucket' => 'amzn-s3-demo-bucket',
'Key' => 'my-key'
]);

Expand Down
2 changes: 1 addition & 1 deletion php/example_code/s3/s3BucketAcl.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
]);

// Gets the access control policy for a bucket
$bucket = 'my-s3-bucket';
$bucket = 'amzn-s3-demo-bucket';
try {
$resp = $s3Client->getBucketAcl([
'Bucket' => $bucket
Expand Down
2 changes: 1 addition & 1 deletion php/example_code/s3/s3BucketPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
'version' => '2006-03-01'
]);

$bucket = 'my-s3-bucket';
$bucket = 'amzn-s3-demo-bucket';

// Get the policy of a specific bucket
try {
Expand Down
2 changes: 1 addition & 1 deletion php/example_code/s3/s3ObjectAcl.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
]);

// Gets the access control list (ACL) of an object.
$bucket = 'my-s3-bucket';
$bucket = 'amzn-s3-demo-bucket';
$key = 'my-object';
try {
$resp = $s3Client->getObjectAcl([
Expand Down
2 changes: 1 addition & 1 deletion php/example_code/s3/s3WebHost.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
]);

// Retrieving the Bucket Website Configuration
$bucket = 'my-s3-bucket';
$bucket = 'amzn-s3-demo-bucket';
try {
$resp = $s3Client->getBucketWebsite([
'Bucket' => $bucket
Expand Down
19 changes: 19 additions & 0 deletions sap-abap/services/s3/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ Code excerpts that show you how to call individual service functions.
- [ListObjectsV2](zcl_aws1_s3_actions.clas.abap#L197)
- [PutObject](zcl_aws1_s3_actions.clas.abap#L216)

### Scenarios

Code examples that show you how to accomplish a specific task by calling multiple
functions within the same service.

- [Create a presigned URL](zcl_aws1_s3_scenario.clas.abap)


<!--custom.examples.start-->
<!--custom.examples.end-->
Expand Down Expand Up @@ -79,6 +86,18 @@ This example shows you how to do the following:
<!--custom.basics.s3_Scenario_GettingStarted.end-->


#### Create a presigned URL

This example shows you how to create a presigned URL for Amazon S3 and upload an object.


<!--custom.scenario_prereqs.s3_Scenario_PresignedUrl.start-->
<!--custom.scenario_prereqs.s3_Scenario_PresignedUrl.end-->


<!--custom.scenarios.s3_Scenario_PresignedUrl.start-->
<!--custom.scenarios.s3_Scenario_PresignedUrl.end-->

### Tests

⚠ Running tests might result in charges to your AWS account.
Expand Down
Loading
Loading