Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Languages / C

Amazon S3 .lib/Dll for Uploading File with Signature Version 4 for VS2010 in C++

5.00/5 (1 vote)
14 Feb 2016CPOL 13.8K   261  
Amazon S3 lib for uploading file in C++ using VS2010

Introduction

Amazon has provided C++ SDK for uploading files to S3 for which you need VS2013. I had made a library project for uploading file to Amazon S3 cloud for Visual Studio 2010 and above using lib CURL. You can use as a .lib or DLL in your project.

Background

Currently, Amazon has provided C++ SDK for Visual Studio 2013. I have made lib for uploading files to Amazon S3 using LIB Curl in Visual Studio 2010. You can extend/modify the library to create, delete , get list of bucket and downloading the file for your Amazon account.

Using the Code

You need to include AmazonS3Upload.h header file and .lib/DLL in your project.

All you need is to provide the below details:

C++
string FilePathToUpload = "c:\songs.mp3";
string bucketName = "mybucket";
string regionUrlPart = "us-east-1";
    
string FilePathAtAmazon = "foldername\";    
string contentType = "media/mpeg";
string strAccesskey = "adasdafas234324";
string strSecretKey = "fgfwt2t2ttertert";

// Use this method to set parameter

pCloudUploadInterface->InitParamenters(FilePathToUpload, bucketName, 
REGION_US_SA_EAST_1, FilePathAtAmazon, contentType, strAccesskey, strSecretKey);

 //To upload file just call the UploadFile().
 int eErrorCode = pCloudUploadInterface->UploadFile();

If ErrorCode 0 means success and other for failure.

On error, you need to call (pCloudUploadInterface->getError())) to get last error details.

This is just an example to upload your files.

You can modify S3Sdk project according to your requirement like getting list of bucket, creating, deleting bucket,setting permission to bucket and downloading file from bucket.

Note: Compile in release mode only.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)