public void addOnProgressListenerTest() { Debug.Log("UploadTask addOnProgressListenerTest"); byte[] data = new byte[100]; string filename = "addOnProgressListenerTest.data"; StorageReference storageReference = mAGCStorageManagement.getStorageReference(filename); UploadTask task = storageReference.putBytes(data, new FileMetadata()); task.addOnProgressListener(new MyProgressListener("1")) .addOnProgressListener(new Activity(), new MyProgressListener("2")) .addOnProgressListener(new MyExecutor("addOnProgressListenerTest"), new MyProgressListener("3")); MyProgressListener remove = new MyProgressListener("remove"); task.addOnProgressListener(remove); task.removeOnProgressListener(remove); bool isInProgress = task.isInProgress(); Debug.Log("UploadTask addOnProgressListenerTest success, is InProgress status: " + isInProgress); }
public AFirebaseDatabaseService() { DatabaseReferences = new Dictionary <string, DatabaseReference>(); ValueEventListeners = new Dictionary <string, IValueEventListener>(); HValueEventListeners = new Dictionary <string, IValueEventListener>(); DValueEventListeners = new Dictionary <string, IValueEventListener>(); RValueEventListeners = new Dictionary <string, IValueEventListener>(); TValueEventListeners = new Dictionary <string, IValueEventListener>(); STValueEventListeners = new Dictionary <string, IValueEventListener>(); PValueEventListeners = new Dictionary <string, IValueEventListener>(); CPValueEventListeners = new Dictionary <string, IValueEventListener>(); ROValueEventListeners = new Dictionary <string, IValueEventListener>(); TKValueEventListeners = new Dictionary <string, IValueEventListener>(); BTValueEventListeners = new Dictionary <string, IValueEventListener>(); BHValueEventListeners = new Dictionary <string, IValueEventListener>(); storageRef = storage.GetReferenceFromUrl(FullUrl); }
private async Task GetVideoUrls() { videoURLs = new Dictionary <string, string>(); foreach (Entry e in allEntries) { Debug.Log("NAME: " + e.GetName() + " URL: " + e.GetUrl()); string entryUrl = e.GetUrl(); string entryName = e.GetName(); StorageReference gs_reference = storage.GetReferenceFromUrl("gs://poppeg-95e96.appspot.com/" + entryUrl); await gs_reference.GetDownloadUrlAsync().ContinueWith((Task <Uri> task) => { if (!task.IsFaulted && !task.IsCanceled) { Debug.Log("Download URL: " + task.Result); videoURLs.Add(entryName, task.Result.ToString()); return; } return; }); } }
// [START upload_from_uri] private void UploadFromUri(Android.Net.Uri fileUri) { Log.Debug(TAG, "uploadFromUri:src:" + fileUri.ToString()); // [START get_child_ref] // Get a reference to store file at photos/<FILENAME>.jpg StorageReference photoRef = mStorageRef.Child("photos") .Child(fileUri.LastPathSegment); // [END get_child_ref] // Upload file to Firebase Storage // [START_EXCLUDE] ShowProgressDialog(); // [END_EXCLUDE] Log.Debug(TAG, "uploadFromUri:dst:" + photoRef.Path); var upload = photoRef.PutFile(fileUri) .AddOnSuccessListener(this, this) .AddOnFailureListener(this, this); }
public void addOnSuccessListenerTest() { Debug.Log("DownloadTask addOnSuccessListenerTest"); StorageReference reference = mAGCStorageManagement.getStorageReference(storageFileName); string downloadFilePath = downloadFileFolder + "addOnSuccessListenerTest.cpp"; File file = new File(downloadFilePath); DownloadTask task = reference.getFile(file); task.addOnSuccessListener(new MySuccessListener("NormalListener")) .addOnSuccessListener(new Activity(), new MySuccessListener("ActivityListener")) .addOnSuccessListener(new MyExecutor("ExecutorListener"), new MySuccessListener("ExecutorListener")); MySuccessListener remove = new MySuccessListener("remove"); task.addOnSuccessListener(remove); task.removeOnSuccessListener(remove); Debug.Log("task.isSuccessful status: " + task.isSuccessful()); Debug.Log("DownloadTask addOnSuccessListenerTest success"); }
public void addOnSuccessListenerTest() { Debug.Log("UploadTask addOnSuccessListenerTest"); byte[] data = new byte[10]; string filename = "addOnSuccessListenerTest.data"; StorageReference storageReference = mAGCStorageManagement.getStorageReference(filename); UploadTask task = storageReference.putBytes(data, new FileMetadata()); task.addOnSuccessListener(new MySuccessListener("NormalListener")) .addOnSuccessListener(new Activity(), new MySuccessListener("ActivityListener")) .addOnSuccessListener(new MyExecutor("ExecutorListener"), new MySuccessListener("ExecutorListener")); MySuccessListener remove = new MySuccessListener("remove"); task.addOnSuccessListener(remove); task.removeOnSuccessListener(remove); Debug.Log("task.isSuccessful status: " + task.isSuccessful()); Debug.Log("UploadTask addOnSuccessListenerTest success"); }
public void addOnProgressListenerTest() { Debug.Log("DownloadTask addOnProgressListenerTest"); StorageReference reference = mAGCStorageManagement.getStorageReference(storageFileName); string downloadFilePath = downloadFileFolder + "addOnProgressListenerTest.cpp"; File file = new File(downloadFilePath); DownloadTask task = reference.getFile(file); task.addOnProgressListener(new MyDownloadProgressListener("1")) .addOnProgressListener(new Activity(), new MyDownloadProgressListener("2")) .addOnProgressListener(new MyExecutor("addOnProgressListenerTest"), new MyDownloadProgressListener("3")); MyDownloadProgressListener remove = new MyDownloadProgressListener("remove"); task.addOnProgressListener(remove); task.removeOnProgressListener(remove); bool isInProgress = task.isInProgress(); Debug.Log("DownloadTask addOnProgressListenerTest success, is InProgress status: " + isInProgress); }
public async Task DownloadReference() { string tourJsonName = "tour.json"; Debug.Log(localDLPath); // download json string localJsonPath = Path.Combine(localDLPath, tourJsonName); StorageReference childref = tourReference.Child(tourJsonName); Debug.Log("DOWNLOADING TO " + localJsonPath); await childref.GetFileAsync(localJsonPath); // download images foreach (string imgName in imgNames) { string localImgPath = Path.Combine(Application.streamingAssetsPath, imgName); localImgPath = Path.Combine(localDLPath, imgName); Debug.Log(localImgPath); await tourReference.Child(imgName).GetFileAsync(localImgPath) .ContinueWith(resultTask => { if (!resultTask.IsFaulted && !resultTask.IsCanceled) { Debug.Log("Download finished."); } else { Debug.Log(resultTask); } }); } Debug.Log("All downloads complete"); }
public static IEnumerator LoadFromCloud(System.Action onComplete) { StorageReference targetStorage = GetTargetCloudStorage(); bool isCompleted = false; bool isSuccessfull = false; const long maxAllowedSize = 1024 * 1024; // Sama dengan 1 MB targetStorage.GetBytesAsync(maxAllowedSize).ContinueWith((Task <byte[]> task) => { if (!task.IsFaulted) { string json = Encoding.Default.GetString(task.Result); Progress = JsonUtility.FromJson <UserProgressData>(json); isSuccessfull = true; } isCompleted = true; }); while (!isCompleted) { yield return(null); } // Jika sukses mendownload, maka simpan data hasil download if (isSuccessfull) { Save(); } else { // Jika tidak ada data di cloud, maka load data dari local LoadFromLocal(); } onComplete?.Invoke(); }
public IEnumerator downloadAndSave2DPieces(string name, GameManager gm) { string pathToSaveIn = Application.persistentDataPath; string chessPiece = "gs://jeremyattardunity.appspot.com/Set1/" + name + ".png"; storage = FirebaseStorage.DefaultInstance; // Create local filesystem URL string filename = Application.persistentDataPath + "/2D.png"; StorageReference storage_ref = storage.GetReferenceFromUrl(chessPiece); // Start downloading a file Task task = storage_ref.GetFileAsync(filename, new Firebase.Storage.StorageProgress <DownloadState>((DownloadState state) => { }), CancellationToken.None); task.ContinueWith(resultTask => { if (!resultTask.IsFaulted && !resultTask.IsCanceled) { } }); yield return(new WaitUntil(() => task.IsCompleted)); Sprite chessPieceSprite = LoadSprite(filename); foreach (GameObject g in GameObject.FindGameObjectsWithTag(name)) { print(g.tag); g.GetComponent <SpriteRenderer>().sprite = chessPieceSprite; } yield return(null); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.Uploadlecture); var toolbarup = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbaruploadvid); SetSupportActionBar(toolbarup); MaterialMenuDrawable materialMenu = new MaterialMenuDrawable(this, Color.Purple, (int)stroke.EXTRA_THIN, MaterialMenuDrawable.DefaultScale, MaterialMenuDrawable.DefaultTransformDuration); materialMenu.SetIconState(MaterialMenuDrawable.IconState.Arrow); toolbarup.NavigationIcon = materialMenu; toolbarup.NavigationClick += delegate { OnBackPressed(); }; Course_name = FindViewById <TextView>(Resource.Id.UploadCourse); done_btn = FindViewById <TextView>(Resource.Id.UploadDone); uploadName = FindViewById <TextView>(Resource.Id.uploadName); uploadPath = FindViewById <TextView>(Resource.Id.uploadPath); uploadSize = FindViewById <TextView>(Resource.Id.uploadSize); uploadEditLectureName = FindViewById <EditText>(Resource.Id.uploadTitleEdit); add_new = FindViewById <FloatingActionButton>(Resource.Id.UploadFab); infoHolder = FindViewById <LinearLayout>(Resource.Id.UploadInfoHolder); itemholder = FindViewById <LinearLayout>(Resource.Id.uploaditemholder); storage = FirebaseStorage.Instance; Storageref = storage.GetReferenceFromUrl("gs://flippedcu.appspot.com").Child("Lectures"); course = Intent.GetStringExtra("course") ?? ""; Course_name.Text = course; done_btn.SetOnClickListener(this); add_new.SetOnClickListener(this); // Create your application here }
// Returns the top times, given the level's database path and map id. // Upload the replay data to Firebase Storage private static Task <StorageMetadata> UploadReplayData( UserScore userScore, ReplayData replay, UploadConfig config) { StorageReference storageRef = FirebaseStorage.DefaultInstance.GetReference(config.storagePath); // Serializing replay data to byte array System.IO.MemoryStream stream = new System.IO.MemoryStream(); replay.Serialize(stream); stream.Position = 0; byte[] serializedData = stream.ToArray(); // Add database path and time to metadata for future usage MetadataChange newMetadata = new MetadataChange { CustomMetadata = new Dictionary <string, string> { { "DatabaseReplayPath", config.dbSharedReplayPath }, { "DatabaseRankPath", config.dbRankPath }, { "Time", userScore.Score.ToString() }, { "Shared", config.shareReplay.ToString() }, } }; return(storageRef.PutBytesAsync(serializedData, newMetadata)); }
public void SetImage(StorageReference Ref) { if (Ref != null) { /*if (bar == null) * { * bar = new ProgressBar(context) * { * Indeterminate = true * }; * mainView.AddView(bar); * }*/ //imageView.Visibility = ViewStates.Invisible; imageName = Ref.Name; Ref.DownloadUrl.AddOnSuccessListener(new Uploader(this)); } else { imageName = null; imageView.SetImageResource(Android.Resource.Drawable.IcMenuGallery); } }
IEnumerator UploadToFirebaseStorage() { StorageReference reference = FirebaseStorage.DefaultInstance .GetReferenceFromUrl(firebaseStorageLocation); #if UNITY_5_0 || UNITY_5_1 || UNITY_5_2 || UNITY_5_3 || UNITY_5_4 var task = reference.PutBytesAsync(Encoding.UTF8.GetBytes(fileContents), null, null, default(System.Threading.CancellationToken), null); #else var task = reference.PutBytesAsync(Encoding.UTF8.GetBytes(fileContents)); #endif yield return(new WaitUntil(() => task.IsCompleted)); if (task.IsFaulted) { DebugLog(task.Exception.ToString()); } else { fileContents = ""; DebugLog("Finished uploading... Download Url: " + task.Result.DownloadUrl.ToString()); DebugLog("Press the Download button to download text from Firebase Storage"); } }
// TODO delete card when all users have downloaded it public async void downloadCard(string fromUserID, string cardID, string mediaNames, string cardName) { // Get proper storage reference to card to download FirebaseStorage storage = FirebaseStorage.Instance; StorageReference sr_card = storage.GetReference("Users") .Child(fromUserID) .Child(cardID); // Create directory for this card IFolder cardDir = await FileSystem.Current.LocalStorage.CreateFolderAsync( Path.Combine(FilePaths.allShareCardsPath, cardID), CreationCollisionOption.ReplaceExisting); // Load in card media files StorageReference sr_cardMedia = sr_card.Child("Media"); List <string> mediaNamesList = destringifyCardMediaNames(mediaNames); List <Java.IO.File> mediaFiles = new List <Java.IO.File>(mediaNamesList.Count); Card card = await FSManager.addNewCardAsync(cardName + " from " + fromUserID); MediaDownloadListener downloadListener = new MediaDownloadListener(mediaNamesList.Count, card, mediaFiles); foreach (string mediaName in mediaNamesList) { if (mediaName != null && mediaName != "") { Java.IO.File file = new Java.IO.File(cardDir.Path, mediaName); sr_cardMedia.Child(mediaName).GetFile(file).AddOnSuccessListener(downloadListener); // TODO add download failure and success handling mediaFiles.Add(file); } } // TODO deletion support for shared cards !!!! // Create new card media contents }
// Upload File to Firebase Storage public IEnumerator UploadToFirebaseStorage(byte[] data, string fileName, string folder, FileCallback Callback) { StorageReference images = storage_ref.Child(folder); #if UNITY_5_0 || UNITY_5_1 || UNITY_5_2 || UNITY_5_3 || UNITY_5_4 var task = reference.PutBytesAsync(Encoding.UTF8.GetBytes(data), null, null, default(System.Threading.CancellationToken), null); #else var task = images.Child(fileName).PutBytesAsync(data); #endif yield return(new WaitUntil(() => task.IsCompleted)); if (task.IsFaulted) { Callback(null, "Error Uploading Enemy Image"); DebugLog(task.Exception.ToString()); throw task.Exception; } else { Callback(task.Result.DownloadUrl.ToString(), "Enemy Image Uploaded Succesfully"); DebugLog("Finished uploading... Download Url: " + task.Result.DownloadUrl.ToString()); } }
public void DownloadFile(string filename) { Debug.Log("Downloading: " + filename); StorageReference path_reference = storage.GetReference(filename); const long maxAllowedSize = 10 * 1024 * 1024; path_reference.GetBytesAsync(maxAllowedSize).ContinueWith((Task <byte[]> task) => { if (task.IsFaulted || task.IsCanceled) { Debug.Log(task.Exception.ToString()); Debug.Log("No case with this name"); } else { Debug.Log("Finished downloading"); Stream stream = new MemoryStream(task.Result); BinaryFormatter bf = new BinaryFormatter(); Case downloadedCase = (Case)bf.Deserialize(stream); UIManager.Instance.activeCase = downloadedCase; downloaded = true; } }); }
/// <summary> /// Downlaod file form current storage location /// </summary> /// <param name="targetPath">current file path</param> /// <returns>file binary file</returns> public async Task <DownloadedFile> DownloadFileFromStorage(string targetPath, FirebaseUser user) { isDonwloaded = true; DownloadedFile current = new DownloadedFile(); Storage_ref = Storage.GetReferenceFromUrl(targetPath); const long maxAllowedSize = 500 * 1024 * 1024; //max donwload file 500MB await Storage_ref.GetBytesAsync(maxAllowedSize).ContinueWith((Task <byte[]> task) => { if (task.IsFaulted || task.IsCanceled) { Debug.Log(task.Exception.ToString()); // Uh-oh, an error occurred! isDonwloaded = false; } else { //save file to byte array current.SetData(task.Result); Debug.Log("Finished downloading!"); } }); await Storage_ref.GetMetadataAsync().ContinueWith((Task <StorageMetadata> task) => { if (!task.IsFaulted && !task.IsCanceled) { StorageMetadata meta = task.Result; current.SetFileType(meta.ContentType); } }); isDonwloaded = false; return(current); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.Dashboard); //Init Firebase auth = FirebaseAuth.GetInstance(MainActivity.app); storage = FirebaseStorage.Instance; storageRef = storage.GetReferenceFromUrl("gs://xamarinapp-67afd.appspot.com"); //create database db = new Database(); db.CreateDatabase(); //View btnLogout = FindViewById <Button>(Resource.Id.dashboard_btn_logout); btnProfile = FindViewById <Button>(Resource.Id.dashboard_user_profile); btnSync = FindViewById <Button>(Resource.Id.dashboard_btn_sync); //upload view init btnChoose = FindViewById <Button>(Resource.Id.btnChoose); btnUpload = FindViewById <Button>(Resource.Id.btnUpload); imgView = FindViewById <ImageView>(Resource.Id.imgView); //upload events btnChoose.Click += delegate { ChooseImage(); }; btnUpload.Click += delegate { UploadImage(); }; activity_dashboard = FindViewById <RelativeLayout>(Resource.Id.activity_dashboard); btnLogout.SetOnClickListener(this); btnProfile.SetOnClickListener(this); btnSync.SetOnClickListener(this); }
public void DownloadFile() { m_text.text = "Yükleniyor..."; storage = FirebaseStorage.GetInstance("gs://ar-demo-309912.appspot.com"); reference = storage.GetReferenceFromUrl(src); string Path = Application.persistentDataPath; if (File.Exists(Path + "/" + local)) { File.Delete(Path + "/" + local); } reference.GetFileAsync(Path + "/" + local).ContinueWithOnMainThread(task => { if (!task.IsFaulted && !task.IsCanceled) { m_text.text = ""; s_download = true; } if (task.IsFaulted) { m_text.text = "Dosyaya ulaşılamadı, böyle bir dosya olmayabilir"; } }); }
private IEnumerator StoreImages(StorageReference storageReference, Item item, string name) { String path = item.id; string id = path.Substring(path.LastIndexOf("/", StringComparison.Ordinal), path.Length); StorageReference reference = storageReference.Child(PathString.Images).Child(name).Child(id); var storagetask = reference.PutFileAsync(path); yield return(new WaitUntil(() => storagetask.IsCompleted)); CodelabUtils._ShowAndroidToastMessage("Upload completed Successfully"); var uritask = storagetask.Result.Reference.GetDownloadUrlAsync(); yield return(new WaitUntil(() => uritask.IsCompleted)); String uri = uritask.Result.ToString(); imageURLs.Add(uri); CodelabUtils._ShowAndroidToastMessage($"Successfully stored Uri to list : {uri}"); //StartCoroutine(GetFileUri(storagetask.Result)); }
public void timePointStateBaseTest() { byte[] data = new byte[100]; string filename = "timePointStateBaseTest.data"; StorageReference storageReference = mAGCStorageManagement.getStorageReference(filename); UploadTask task = storageReference.putBytes(data, new FileMetadata()); StorageTask.ErrorResult err = task.getTimePointState(); StorageTask.TimePointStateBase timePoint = HmsUtil.GetHmsBase <StorageTask.TimePointStateBase>(err.obj); Exception e = timePoint.getError(); if (e == null) { Debug.Log("timePointStateBaseTest fail, error result is null"); return; } StorageReference timeRef = timePoint.getStorage(); if (timeRef == null) { Debug.Log("timePointStateBaseTest fail, timeRef is null"); return; } StorageTask storageTask = timePoint.getTask(); if (storageTask == null) { Debug.Log("timePointStateBaseTest fail, storageTask is null"); return; } Debug.Log("timePointStateBaseTest success"); }
private void downloadTest() { Debug.Log("downloadTest start"); StorageReference reference = mAGCStorageManagement.getStorageReference(storageFileName); Debug.Log("getStorageReference end"); string downloadFilePath = downloadFileFolder + "downloadTest.cpp"; Debug.Log("downloadFilePath: " + downloadFilePath); File file = new File(downloadFilePath); try { DownloadTask task = reference.getFile(file); if (task == null) { Debug.Log("downloadTask is null"); } else { Debug.Log("downloadTask is not null"); StorageTask.ErrorResult err = new MyErrorResult(); Exception e = err.getError(); task.setResult(err.obj); err = task.getResult(); if (err == null) { Debug.Log("downloadFileTest fail, getResult err is null."); return; } StorageTask.ErrorResult timePointState = task.getTimePointState(); if (timePointState == null) { Debug.Log("downloadFileTest fail, getTimePointState result is null."); return; } Exception exp = task.getException(); if (exp == null) { Debug.Log("downloadFileTest fail, getException result is null."); return; } task.setException(exp); AndroidJavaObject ajObj = task.getResultThrowException(new AndroidJavaClass("java.lang.Exception")); if (ajObj == null) { Debug.Log("downloadFileTest fail, getException result is null."); return; } Debug.Log("downloadTest Success"); } } catch (System.Exception e) { Debug.Log(e); } }
void ConnectViews() { Fnametext = (TextInputLayout)FindViewById(Resource.Id.fullnametext); emtext = (TextInputLayout)FindViewById(Resource.Id.emailtext); passtext = (TextInputLayout)FindViewById(Resource.Id.passwordtext); submit = (Button)FindViewById(Resource.Id.submit_btn); login = (Button)FindViewById(Resource.Id.login_btn); googlelogin = (Button)FindViewById(Resource.Id.googlelogin_btn); profimg = (ImageView)FindViewById(Resource.Id.profileiv); gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DefaultSignIn) .RequestIdToken("228992356302-n0p15tka3tqvhps5e7ra7scrs6fqg0p0.apps.googleusercontent.com") .RequestEmail().Build(); googleapiclient = new GoogleApiClient.Builder(this).AddApi(Auth.GOOGLE_SIGN_IN_API, gso).Build(); googleapiclient.Connect(); submit.Click += (sender, e) => { if (imageArray == null) { imageArray = System.IO.File.ReadAllBytes("Resources/Images/DefaultUser.png"); } storageReference = FirebaseStorage.Instance.GetReference($"users/{Fnametext.EditText.Text}_image"); storageReference.PutBytes(imageArray); storageReference.GetDownloadUrl().AddOnSuccessListener(this); HashMap map = new HashMap(); map.Put("fullname", Fnametext.EditText.Text); map.Put("email", emtext.EditText.Text); map.Put("password", passtext.EditText.Text); map.Put("profileimage", url); DocumentReference docRef = database.Collection("users").Document(); docRef.Set(map); Toast.MakeText(this, "User Registered", ToastLength.Long).Show(); FetchUserData(); }; login.Click += (sender, e) => { string loginfname = Fnametext.EditText.Text.ToString(); string loginemail = emtext.EditText.Text.ToString(); string loginpass = passtext.EditText.Text.ToString(); //listOfUser=userservice.FetchUserData("user"); //while (listOfUser.Count == 0) //{ //} foreach (var item in listOfUser) { Console.WriteLine("Fullname: " + item.Fullname); } foreach (var item in listOfUser) { if (item.Fullname.Equals(loginfname) && item.Email.Equals(loginemail) && item.password.Equals(loginpass)) { Intent secondpageintent = new Intent(this, typeof(SecondPageActivity)); secondpageintent.PutExtra("accepteduser", JsonConvert.SerializeObject(item)); StartActivity(secondpageintent); return; } } Toast.MakeText(this, "Invalid Credentials", ToastLength.Long).Show(); return; }; profimg.Click += (sender, e) => { RequestPermissions(permissionGroup, 0); var trans = SupportFragmentManager.BeginTransaction(); uploadimg = new UploadImageFragment(); uploadimg.Show(trans, "profilepicmethod"); uploadimg.uploadImage += (Bitmap bitmap, byte[] imgary) => { profimg.SetImageBitmap(bitmap); imageArray = imgary; uploadimg.Dismiss(); }; }; googlelogin.Click += (sender, e) => { var intent = Auth.GoogleSignInApi.GetSignInIntent(googleapiclient); StartActivityForResult(intent, 1); }; }
private static Task DownloadCommon(string firebaseFolder, string firebaseFileName, string destination) { StorageReference downloadReference = FirebaseStorage.DefaultInstance.RootReference.Child(firebaseFolder).Child(firebaseFileName); return(downloadReference.GetFileAsync(destination)); }
public StorageReferenceWrapper(StorageReference storageReference) { _storageReference = storageReference ?? throw new ArgumentNullException(nameof(storageReference)); }
public UserController() { userNode = AppDelegate.rootNode.GetChild("users"); imagesRef = AppDelegate.rootRefStorage.GetChild("images"); }
public StorageReferenceWrapper(StorageReference reference) { _wrapped = reference; }
public static IStorageReference ToAbstract(this StorageReference @this) { return(new StorageReferenceWrapper(@this)); }
public IEnumerator downloadAndSaveImage() { if (RandomNumBG == 1) { string pathToSaveIn = Application.persistentDataPath; storage = FirebaseStorage.DefaultInstance; // Create local filesystem URL string filename = Application.persistentDataPath + "/image1.jpg"; StorageReference storage_ref = storage.GetReferenceFromUrl("gs://chadleychess.appspot.com/image1.jpg"); // Start downloading a file Task task = storage_ref.GetFileAsync(filename, new Firebase.Storage.StorageProgress <DownloadState>((DownloadState state) => { // called periodically during the download Debug.Log(String.Format( "Progress: {0} of {1} bytes transferred.", state.BytesTransferred, state.TotalByteCount )); }), CancellationToken.None); task.ContinueWith(resultTask => { if (!resultTask.IsFaulted && !resultTask.IsCanceled) { Debug.Log("Download finished."); } }); Debug.Log(filename); yield return(new WaitUntil(() => task.IsCompleted)); Sprite bgimg = LoadSprite(filename); GameObject.Find("backgroundImage").GetComponent <Image>().sprite = bgimg; } else if (RandomNumBG == 2) { string pathToSaveIn = Application.persistentDataPath; storage = FirebaseStorage.DefaultInstance; // Create local filesystem URL string filename = Application.persistentDataPath + "/image2.jpg"; StorageReference storage_ref = storage.GetReferenceFromUrl("gs://chadleychess.appspot.com/image2.jpg"); // Start downloading a file Task task = storage_ref.GetFileAsync(filename, new Firebase.Storage.StorageProgress <DownloadState>((DownloadState state) => { // called periodically during the download Debug.Log(String.Format( "Progress: {0} of {1} bytes transferred.", state.BytesTransferred, state.TotalByteCount )); }), CancellationToken.None); task.ContinueWith(resultTask => { if (!resultTask.IsFaulted && !resultTask.IsCanceled) { Debug.Log("Download finished."); } }); Debug.Log(filename); yield return(new WaitUntil(() => task.IsCompleted)); Sprite bgimg = LoadSprite(filename); GameObject.Find("backgroundImage").GetComponent <Image>().sprite = bgimg; } else if (RandomNumBG == 3) { string pathToSaveIn = Application.persistentDataPath; storage = FirebaseStorage.DefaultInstance; // Create local filesystem URL string filename = Application.persistentDataPath + "/image3.jfif"; StorageReference storage_ref = storage.GetReferenceFromUrl("gs://chadleychess.appspot.com/image3.jfif"); // Start downloading a file Task task = storage_ref.GetFileAsync(filename, new Firebase.Storage.StorageProgress <DownloadState>((DownloadState state) => { // called periodically during the download Debug.Log(String.Format( "Progress: {0} of {1} bytes transferred.", state.BytesTransferred, state.TotalByteCount )); }), CancellationToken.None); task.ContinueWith(resultTask => { if (!resultTask.IsFaulted && !resultTask.IsCanceled) { Debug.Log("Download finished."); } }); Debug.Log(filename); yield return(new WaitUntil(() => task.IsCompleted)); Sprite bgimg = LoadSprite(filename); GameObject.Find("backgroundImage").GetComponent <Image>().sprite = bgimg; } else if (RandomNumBG == 4) { string pathToSaveIn = Application.persistentDataPath; storage = FirebaseStorage.DefaultInstance; // Create local filesystem URL string filename = Application.persistentDataPath + "/image4.jpg"; StorageReference storage_ref = storage.GetReferenceFromUrl("gs://chadleychess.appspot.com/image4.jpg"); // Start downloading a file Task task = storage_ref.GetFileAsync(filename, new Firebase.Storage.StorageProgress <DownloadState>((DownloadState state) => { // called periodically during the download Debug.Log(String.Format( "Progress: {0} of {1} bytes transferred.", state.BytesTransferred, state.TotalByteCount )); }), CancellationToken.None); task.ContinueWith(resultTask => { if (!resultTask.IsFaulted && !resultTask.IsCanceled) { Debug.Log("Download finished."); } }); Debug.Log(filename); yield return(new WaitUntil(() => task.IsCompleted)); Sprite bgimg = LoadSprite(filename); GameObject.Find("backgroundImage").GetComponent <Image>().sprite = bgimg; } yield return(null); }