# Xamarin

## What is Xamarin?

Xamarin is a mobile application development platform for Windows, iOS and Android applications. An Xamarin app can be built with the .NET and C# frameworks using Xamarin Studio or in Microsoft's [Visual Studio](https://visualstudio.microsoft.com/downloads/). The [AWS Transfer Utility](https://docs.aws.amazon.com/amplify/?id=docs_gateway) can be configured within an Xamarin app to connect to Filebase.

{% hint style="success" %}

### Prerequisites:

* [x] [Download and install](https://visualstudio.microsoft.com/downloads/) Visual Studio (Version 2019 or older).
* [x] [Sign up](https://filebase.com/signup) for a free Filebase account.&#x20;
* [x] Have your Filebase Access and Secret Keys. Learn how to view your access keys [here](https://docs.filebase.com/getting-started-guides/getting-started-guide#working-with-access-keys).
* [x] Create a Filebase Bucket. Learn how to create a bucket [here](https://docs.filebase.com/getting-started-guides/getting-started-guide#creating-and-working-with-buckets).
  {% endhint %}

### 1. Install the 'Mobile Development with .NET' Tool Package for Visual Studio.

This workload package includes the templates and frameworks for Xamarin.

![](https://3861818989-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lyjw7dWpiQtUFDa1pO0%2Fuploads%2FGpMmuCisnmGkHTSrClzc%2Fimage.png?alt=media\&token=dc177675-9509-4983-8f90-23967cf3cc53)

### 2. Create or open a Visual Studio project.

### 3. Within your Visual Studio project, view your SolutionExplorer > Packages > Manage NuGet Packages.

![](https://3861818989-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lyjw7dWpiQtUFDa1pO0%2Fuploads%2FPqwRpk5V0Na3MXxmWKvE%2Fimage.png?alt=media\&token=2ed5e14d-113c-4723-984f-36294dd878f3)

### 4. Browse for and install the following NuGets:

* **AWSSDK.S3**
* **AwsSignatureVersion4**

![](https://3861818989-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lyjw7dWpiQtUFDa1pO0%2Fuploads%2FcNmYXibWscQ16f1mjlAQ%2Fimage.png?alt=media\&token=65b7b4e7-00ac-4b94-94c1-ded8e6355667)

### 5. Configure your Xamarin app as desired for use with Filebase.

{% hint style="warning" %}
Xamarin includes a wide range of implementation for creating Android, iOS, and Windows Applications. This code snippet is a single example of a stand alone file download. This does not include other application functionality, such as a User Interface or Button configuration. Filebase is unable to provide specific configurations for custom applications due to their individualized nature.
{% endhint %}

#### The following code example showcases how to download a file from Filebase:

```csharp
using System;
using System.IO;
using Amazon.S3;
using Amazon.S3.Model;
using Amazon.S3.Util;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            AmazonS3Config s3Config = new AmazonS3Config
            {
                ServiceURL = "https://s3.filebase.com",
            };
            var accessKey = "Filebase Access Key";
            var secretKey = "Filebase Secret Key";

            var s3Client = new AmazonS3Client(accessKey, secretKey, s3Config);
            var transferUtility = new Amazon.S3.Transfer.TransferUtility(s3Client);

            transferUtility.Download("Local/Path/To/Download/File/File.name",
                                     "Filebase-Bucket-Name",
                                     "Object-Name-To-Download");
        }
    }
}
```

Edit this code with your:

* **Filebase Access Key**
* **Filebase Secret Key**
* **Local Path Where To Download The File To**
* **Filebase Bucket Name**
* **Object Name to be Downloaded**

#### The following code example showcases how to upload a file to Filebase:

```javascript
using System;
using System.IO;
using Amazon.S3;
using Amazon.S3.Model;
using Amazon.S3.Util;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            AmazonS3Config s3Config = new AmazonS3Config
            {
                ServiceURL = "https://s3.filebase.com",
            };
            var accessKey = "Filebase Access Key";
            var secretKey = "Filebase Secret Key";

            var s3Client = new AmazonS3Client(accessKey, secretKey, s3Config);
            var transferUtility = new Amazon.S3.Transfer.TransferUtility(s3Client);

            transferUtility.Upload("Local/Path/To/File/To/Upload",
                                     "Filebase-Bucket-Name");
        }
    }
}
```

Edit this code with your:

* **Filebase Access Key**
* **Filebase Secret Key**
* **Local Path Where The File To Upload Is Located**
* **Filebase Bucket Name**
