UploadContent (Unity)
- Declaration
public static void UploadContent(string localFilePath, Action<CavrnusRemoteContent> onUploadComplete, Dictionary<string, string> tags = null)
- Description
Encrypts and uploads a file from your disk to your Cavrnus Server. From here it will be accessible for your clients to download (in encrypted form) via the FetchFileById call.
At all points of the process the files are encrypted and are only provided to clients via a Stream. Note though, that if those clients had API access and were authenticated on your server then they could write that stream to their disk as an unencrypted file. This is unavoidable as your developers obviously need to process those streams and display them in Unity.
onUploadComplete
returns a CavrnusRemoteContent object representing the file you just uploaded. If you wish you can then fetch it, or post it’s Id as a string property so other users can also fetch it.
- Sample
using CavrnusSdk.API;
using System.Collections.Generic;
using UnityEngine;
public class SampleClickUploader : MonoBehaviour
{
public string filePathToUpload;
private void DoUpload()
{
CavrnusFunctionLibrary.UploadContent(filePathToUpload, crc =>
{
Debug.Log($"{filePathToUpload} successfully uploaded! ContentId: {crc.Id}");
}, new Dictionary<string, string>() { { "testTag", "testValue" } });
}
}