Realm.LFS.Azure
1.1.0
dotnet add package Realm.LFS.Azure --version 1.1.0
NuGet\Install-Package Realm.LFS.Azure -Version 1.1.0
<PackageReference Include="Realm.LFS.Azure" Version="1.1.0" />
paket add Realm.LFS.Azure --version 1.1.0
#r "nuget: Realm.LFS.Azure, 1.1.0"
// Install Realm.LFS.Azure as a Cake Addin #addin nuget:?package=Realm.LFS.Azure&version=1.1.0 // Install Realm.LFS.Azure as a Cake Tool #tool nuget:?package=Realm.LFS.Azure&version=1.1.0
Realm LFS Azure
Realm LFS (large file storage) is an extension of the Realm.NET SDK that exposes an abstraction for interacting with binary files that are transparently uploaded to a 3rd party service (e.g. S3/Azure Blob Storage) and their URL is subsequently updated in the Realm object for other clients to consume.
This package supplies a RemoteStorageManager
implementation for the Realm.LFS
that uploads the files to Azure Blob Storage.
Usage
For the most part, just replace byte[]
properties with FileData
ones:
public class Recipe : RealmObject
{
public string Name { get; set; }
public string Summary { get; set; }
public IList<Ingredient> Ingredients { get; set; }
// Replace this
public byte[] Photo { get; set; }
// with this
public FileData Photo { get; set; }
}
To initialize the SDK, the minimum configuration you need to do is to configure the remote manager factory:
var connectionString = "...";
LFSManager.Initialize(new LFSOptions
{
RemoteManagerFactory = (config) => new AzureStorageManager(config, connectionString)
});
The FileData
class can be constructed from a Stream
- if you already have a byte[]
, that can be used to create a MemoryStream
.
When displaying an image from a FileData
, the code should look something like:
public void PopulateImage(Recipe recipe)
{
switch (recipe.Photo.Status)
{
case DataStatus.Local:
var imagePath = recipe.Photo.LocalUrl;
if (File.Exists(imagePath))
{
// we are the device that created the image - display it from disk
MyImage.ImageSource = new FileImageSource(imagePath);
}
else
{
// this image was created on another device, but it hasn't uploaded it yet
// to Blob Storage. Display a placeholder until the status changes to Remote
MyImage.ImageSource = placeHolderImage;
}
break;
case DataStatus.Remote:
MyImage.ImageSource = new ImageSource(recipe.Photo.Url);
break;
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- Microsoft.Azure.Storage.DataMovement (>= 2.0.4)
- Realm.LFS (>= 1.1.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.