Skip to content

Instantly share code, notes, and snippets.

View alexandre-bruffa's full-sized avatar

Alexandre Bruffa alexandre-bruffa

View GitHub Profile
import json
import urllib.parse
# We work with the layer we created
import firebase_admin
from firebase_admin import messaging
from firebase_admin import credentials
import boto3
pip install --upgrade pip
pip install firebase-admin
// In the Awake function, we configure the s3 client
private void Awake()
{
AmazonS3Config s3Config = new AmazonS3Config();
s3Config.RegionEndpoint = Amazon.RegionEndpoint.USEast1;
s3Client = new AmazonS3Client(awsAccessKeyId, awsSecretAccessKey, s3Config);
}
private async void GetTokenAsync()
{
// We get the Firebase device token and we copy it in the clipboard
string token = await Firebase.Messaging.FirebaseMessaging.GetTokenAsync();
GUIUtility.systemCopyBuffer = token;
}
public async void PlayVideo(string videoName)
{
// We check if the file exists
bool fileDownloaded = System.IO.File.Exists($"{Application.persistentDataPath}/Videos/{videoName}");
// if it does exist on the device, we download it
if (!fileDownloaded)
{
fileDownloaded = await FileManager.DownloadObjectFromBucketAsync(fileManager.s3Client, videoName);
}
public static async Task<bool> DownloadObjectFromBucketAsync(IAmazonS3 client, string objectName)
{
// Create a GetObject request
var request = new GetObjectRequest
{
BucketName = Utils.awsBucket,
Key = objectName,
};
// Issue request and remember to dispose of the response
public static async Task<List<string>> ListBucketContentsAsync(IAmazonS3 client)
{
List<string> files = new List<string>();
try
{
// We build the request
var request = new ListObjectsV2Request
{
BucketName = Utils.awsBucket,
private async void StartUploadVideo()
{
bool response = await FileManager.UploadFileAsync(fileManager.s3Client, webCam.name, $"{fileName}.mp4", $"{Application.dataPath}Videos/{fileName}.mp4");
}
using System.Threading.Tasks;
using Amazon;
using Amazon.S3;
using Amazon.S3.Model;
using UnityEngine;
public class FileManager : MonoBehaviour
{
public IAmazonS3 s3Client;
using UnityEngine;
using UnityEditor;
using UnityEditor.Recorder;
using UnityEditor.Recorder.Input;
private RecorderController recorderController;
private MovieRecorderSettings videoRecorder;
private string fileName;