Xamarin
Learn how to connect your Xamarin app to Filebase.

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. The AWS Transfer Utility can be configured within an Xamarin app to connect to Filebase.

Prerequisites:

  • Download and install Visual Studio (Version 2019 or older)
  • Have Your Filebase Access and Secret Keys. Learn how to view your access keys here.
  • Create a Filebase Bucket. Learn how to create a bucket here.

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

This workload package includes the templates and frameworks for Xamarin.

2. Create or open a Visual Studio project.

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

4. Browse for and install the following NuGets:

  • AWSSDK.S3
  • AwsSignatureVersion4

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

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.

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

1
using System;
2
using System.IO;
3
using Amazon.S3;
4
using Amazon.S3.Model;
5
using Amazon.S3.Util;
6
7
namespace ConsoleApp1
8
{
9
class Program
10
{
11
static void Main(string[] args)
12
{
13
AmazonS3Config s3Config = new AmazonS3Config
14
{
15
ServiceURL = "https://s3.filebase.com",
16
};
17
var accessKey = "Filebase Access Key";
18
var secretKey = "Filebase Secret Key";
19
20
var s3Client = new AmazonS3Client(accessKey, secretKey, s3Config);
21
var transferUtility = new Amazon.S3.Transfer.TransferUtility(s3Client);
22
23
transferUtility.Download("Local/Path/To/Download/File/File.name",
24
"Filebase-Bucket-Name",
25
"Object-Name-To-Download");
26
}
27
}
28
}
Copied!
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:

1
using System;
2
using System.IO;
3
using Amazon.S3;
4
using Amazon.S3.Model;
5
using Amazon.S3.Util;
6
7
namespace ConsoleApp1
8
{
9
class Program
10
{
11
static void Main(string[] args)
12
{
13
AmazonS3Config s3Config = new AmazonS3Config
14
{
15
ServiceURL = "https://s3.filebase.com",
16
};
17
var accessKey = "Filebase Access Key";
18
var secretKey = "Filebase Secret Key";
19
20
var s3Client = new AmazonS3Client(accessKey, secretKey, s3Config);
21
var transferUtility = new Amazon.S3.Transfer.TransferUtility(s3Client);
22
23
transferUtility.Upload("Local/Path/To/File/To/Upload",
24
"Filebase-Bucket-Name");
25
}
26
}
27
}
Copied!
Edit this code with your:
  • Filebase Access Key
  • Filebase Secret Key
  • Local Path Where The File To Upload Is Located
  • Filebase Bucket Name
If you have any questions, please join our Discord server, or send us an email at [email protected]