1. Install mono and associated tools, mozroots downloads root certificates to enable SSL via mono:
sudo apt-get update
sudo apt-get install mono-complete git wget
mozroots --import --sync
2. Create a working directory and change to it:
mkdir mono-aws
cd mono-aws
3. Download the command line version of NuGet and verify that it is version 2.8+:
wget http://nuget.org/nuget.exe
mono nuget.exe update -self
4. Install the AWSSDK via NuGet:
mono nuget.exe install AWSSDK
5. Create a symbolic link to the lib folder (note that the version number might be different from the example command):
ln -s AWSSDK.2.1.6.0/lib/net35 lib
6. Create a command line program to test with, for example in s3.cs:
using System;
using Amazon.S3;
using Amazon.S3.Model;
class Upload
{
public static void Main(string[] args)
{
// Create a client
AmazonS3Client client = new AmazonS3Client(Amazon.RegionEndpoint.USWest2);
// Create a PutObject request
PutObjectRequest request = new PutObjectRequest
{
BucketName = "SampleBucket",
Key = "Item1",
ContentBody = "This is sample content..."
};
// Put object
client.PutObject(request);
}
}
7. Compile your program:
mcs s3.cs -r:./lib/AWSSDK.dll
8. Set the Mono path
export MONO_PATH=`pwd`/lib:.
9. Create an application configuration (must be named to match the compiled program) for example in s3.exe.config:
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="AWSAccessKey" value="AKXXXXXXXXXXXXXX"/>
<add key="AWSSecretKey" value="XXXXXXXXXXXXXXXXXXXXXXXX"/>
</appSettings>
</configuration>
10. Run your program and verify that the object is created in the bucket:
mono s3.exe
6. Create a command line program to test with, for example in s3.cs:
using System;
using Amazon.S3;
using Amazon.S3.Model;
class Upload
{
public static void Main(string[] args)
{
// Create a client
AmazonS3Client client = new AmazonS3Client(Amazon.RegionEndpoint.USWest2);
// Create a PutObject request
PutObjectRequest request = new PutObjectRequest
{
BucketName = "SampleBucket",
Key = "Item1",
ContentBody = "This is sample content..."
};
// Put object
client.PutObject(request);
}
}
7. Compile your program:
mcs s3.cs -r:./lib/AWSSDK.dll
8. Set the Mono path
export MONO_PATH=`pwd`/lib:.
9. Create an application configuration (must be named to match the compiled program) for example in s3.exe.config:
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="AWSAccessKey" value="AKXXXXXXXXXXXXXX"/>
<add key="AWSSecretKey" value="XXXXXXXXXXXXXXXXXXXXXXXX"/>
</appSettings>
</configuration>
10. Run your program and verify that the object is created in the bucket:
mono s3.exe