This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pip install --upgrade pip | |
pip install firebase-admin | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private async void StartUploadVideo() | |
{ | |
bool response = await FileManager.UploadFileAsync(fileManager.s3Client, webCam.name, $"{fileName}.mp4", $"{Application.dataPath}Videos/{fileName}.mp4"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Threading.Tasks; | |
using Amazon; | |
using Amazon.S3; | |
using Amazon.S3.Model; | |
using UnityEngine; | |
public class FileManager : MonoBehaviour | |
{ | |
public IAmazonS3 s3Client; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using UnityEditor; | |
using UnityEditor.Recorder; | |
using UnityEditor.Recorder.Input; | |
private RecorderController recorderController; | |
private MovieRecorderSettings videoRecorder; | |
private string fileName; |
NewerOlder