public void UploadFile() { // Get a reference to the storage service, using the default Firebase App FirebaseStorage storage = FirebaseStorage.DefaultInstance; // FirebaseStorage storage = FirebaseStorage.GetInstance("gs://basicfileupload.appspot.com") ; // Create a storage reference from our storage service StorageReference storage_ref = storage.GetReferenceFromUrl("gs://basicfileupload.appspot.com"); // Create a child reference // images_ref now points to "images" StorageReference testFileRef = storage_ref.Child($"Testing/{fileName.text}"); string download_url; // Upload the file to the path "images/rivers.jpg" testFileRef.PutFileAsync(fileName.text) .ContinueWith((Task <StorageMetadata> task) => { if (task.IsFaulted || task.IsCanceled) { Debug.Log(task.Exception.ToString()); } else { Task <Uri> dloadTask = testFileRef.GetDownloadUrlAsync(); download_url = dloadTask.Result.ToString(); Debug.Log("Finished uploading..."); Debug.Log("download url = " + download_url); } }); }
public static void UploadFile(string File, string Path, string Type, string Database) { StorageReference FileReference = StorageReference.Child(Path); var Metadata = new MetadataChange(); Metadata.ContentType = "image/" + Type.Replace(".", ""); FileReference.PutFileAsync(File, Metadata).ContinueWith((Task) => { if (Task.IsFaulted || Task.IsCanceled) { Debug.Log(Task.Exception.ToString()); TecWolf.System.SystemInterface.Alert("Foto não enviada com sucesso, tente novamente."); } else { TecWolf.System.SystemInterface.Alert("Foto enviada com sucesso."); FileReference.GetDownloadUrlAsync().ContinueWith(TaskDownload => { if (TaskDownload.IsCompleted) { Debug.Log("Download URL: " + TaskDownload.Result); DownloadUrl = TaskDownload.Result.ToString(); FirebaseController.WriteDataString(Database, "link", FirebaseController.DownloadUrl); } }); } }); }
public void GetSprite() { Debug.Log($"StorageManager Requesting image at {itemPath}"); // get reference to the itemPath StorageReference reference = StorageManager.storageReference.GetReferenceFromUrl(itemPath); uri = null; // launch coroutine to wait for the Uri to be set StartCoroutine(GetImage(image)); reference.GetDownloadUrlAsync().ContinueWith((task) => { if (!task.IsFaulted && !task.IsCanceled) { print($"URI {task.Result}"); uri = task.Result; } else { print($"StorageManager Requesting image Failed"); } }); }
public void UploadProfilePic() { FirebaseStorage storage = FirebaseStorage.DefaultInstance; StorageReference storage_ref = GetStorageReference(); var profilePicReference = storage_ref.Child("images/" + auth.CurrentUser.Email); Byte[] profile = FacebookManager.Instance.ProfileTexture.EncodeToPNG(); profilePicReference.PutBytesAsync(profile) .ContinueWith((Task <StorageMetadata> task) => { if (task.IsFaulted || task.IsCanceled) { Debug.Log(task.Exception.ToString()); // Uh-oh, an error occurred! } else { // Metadata contains file metadata such as size, content-type, and download URL. Firebase.Storage.StorageMetadata metadata = task.Result; string download_url = storage_ref.GetDownloadUrlAsync().ToString(); Debug.Log("Finished uploading..."); Debug.Log("download url = " + download_url); } }); }
public async void OnComplete(Android.Gms.Tasks.Task task) { if (task.IsSuccessful) { var imageUrl = await _storageReference.GetDownloadUrlAsync(); string imageUrlString = imageUrl.ToString(); _tcs.TrySetResult(imageUrl.ToString()); } }
public void getDownloadUrl(string fbPath, Action <Uri> cb) { authDoneCB.add(() => { StorageReference reference = getByPath(fbPath); reference.GetDownloadUrlAsync().ContinueWith(tk => UnityMainThreadDispatcher.uniRxRun(() => { cb(tk.Result); }) ); }); }
public async void DownloadingImage() { try { Uri uri = await imageStorage_ref.GetDownloadUrlAsync(); StartCoroutine(GetImageFromFirebase(uri)); } catch (Exception ex) { Debug.LogError(ex.InnerException.Message); } }
public async Task <Uri> GetDownloadUrlAsync() { try { var url = await _storageReference.GetDownloadUrlAsync().ConfigureAwait(false); return(new Uri(url.AbsoluteString)); } catch (NSErrorException e) { throw ExceptionMapper.Map(e); } }
public static void GetURLDownload(string hatName, UnityAction <UnityEngine.Object, UnityEngine.Object> URLS) { #if UNITY_ANDROID string Platform = "android"; #elif UNITY_IOS string Platform = "ios"; #endif string modelURL = ConstantStorageURL + "/" + "Hats" + "/" + Platform + "/" + hatName; string contentURL = ConstantStorageURL + "/" + "Hats" + "/" + Platform + "/" + hatName + "_content"; gs_referenceM = storage.GetReferenceFromUrl(modelURL); gs_referenceC = storage.GetReferenceFromUrl(contentURL); GG(gs_referenceM.GetDownloadUrlAsync(), gs_referenceC.GetDownloadUrlAsync(), hatName, URLS); }
public async void OnSuccess(Java.Lang.Object result) { if (storageRef != null) { var url = await storageRef.GetDownloadUrlAsync(); //Toast.MakeText(context, $"{r.ToString()}", ToastLength.Long).Show(); if (url != null) { await query.UpdateAsync("ImageUrl", url.ToString()); } } }
private async void DownloadImage() { try { Uri uri = await imageStorage_ref.GetDownloadUrlAsync(); StartCoroutine(LoadCoroutine(uri)); } catch (Exception ex) { Debug.LogError(ex.InnerException.Message); } }
// Use this for initialization void Start() { StorageReference imgRef = FirebaseStorage.DefaultInstance.GetReferenceFromUrl("gs://gabudnus.appspot.com/gambar/wacana.co_Rumah-Adat-Joglo-1170x780.jpg"); imgRef.GetDownloadUrlAsync().ContinueWith((Task <Uri> task) => { if (!task.IsFaulted && !task.IsCanceled) { string url = task.Result.ToString(); Debug.Log(url); StartCoroutine(LoadURL(url)); } }); }
// Retorna un link temporal que apunta directamente al archivo // con el assetbundle del id especificado. private async Task <string> GetFileUrlFromFirebase(string id) { StorageReference storage_ref = _firebasestorage.GetReferenceFromUrl(firebaseBasePath + id); string link = ""; await storage_ref.GetDownloadUrlAsync().ContinueWith((Task <Uri> task) => { if (!task.IsFaulted && !task.IsCanceled) { link = task.Result.ToString(); } }); return(link); }
private IEnumerator GetImageURL(Recipe recipe) { StorageReference reference = StorageManager.storageReference.GetReferenceFromUrl(recipe.ImageReferencePath); reference.GetDownloadUrlAsync().ContinueWith((task) => { if (!task.IsFaulted && !task.IsCanceled) { recipe.RootImagePath = task.Result.ToString(); } }); yield return(new WaitUntil(() => recipe.RootImagePath != null)); }
/* The function call to be allowed only if network is available * Get yipli pc app url from backend */ public static async Task <string> GetYipliWinAppUpdateUrl() { Uri appUpdateUrl = null; try { StorageReference reference = yipliStorage.GetReferenceFromUrl(StoragePath + "Yipli_Setup.exe"); appUpdateUrl = await reference.GetDownloadUrlAsync(); } catch (Exception exp) { Debug.Log("Failed to Get app win version : " + exp.Message); } return(appUpdateUrl.ToString()); }
void GetImage() { Debug.Log(1); FirebaseStorage storage = FirebaseStorage.DefaultInstance; StorageReference pathRef = storage.GetReference("images/20210731055838368.png"); pathRef.GetDownloadUrlAsync().ContinueWith(task => { if (!task.IsFaulted && !task.IsCanceled) { path = task.Result.ToString(); Debug.Log(path); //aaaa(); StartCoroutine(WaitRequest()); } }); }
public void GetSprite() { Debug.Log($"StorageManager Requesting image at {itemPath}"); if (string.IsNullOrWhiteSpace(itemPath)) { print("No imagepath so using black texture"); var black = Texture2D.blackTexture; image.sprite = Sprite.Create(black, new Rect(Vector2.zero, new Vector2(black.width, black.height)), new Vector2(0.5f, 00.5f)); Destroy(gameObject); return; } // get reference to the itemPath StorageReference reference = StorageManager.storageReference.GetReferenceFromUrl(itemPath); reference.GetDownloadUrlAsync().ContinueWithOnMainThread((task) => { if (!task.IsFaulted && !task.IsCanceled) { print($"URI {task.Result}"); var request = UnityWebRequestTexture.GetTexture(task.Result); var operation = request.SendWebRequest(); operation.completed += asyncOperation => { var texture = ((DownloadHandlerTexture)request.downloadHandler).texture; try { image.sprite = Sprite.Create(texture, new Rect(Vector2.zero, new Vector2(texture.width, texture.height)), new Vector2(0.5f, 0.5f)); } catch (Exception e) { Debug.Log(e); } Destroy(gameObject); }; } else { print($"StorageManager Requesting image Failed"); } }); }
public void DownloadFileURL(string url) { FirebaseStorage storage = FirebaseStorage.DefaultInstance; // Create a reference from a Google Cloud Storage URI StorageReference gsReference = storage.GetReferenceFromUrl("gs://konnekt4march.appspot.com" + url); // Fetch the download URL gsReference.GetDownloadUrlAsync().ContinueWith(task => { if (!task.IsFaulted && !task.IsCanceled) { Debug.Log("Download URL: " + task.Result); _downloadUrlComplete?.Invoke(task.Result.ToString()); // ... now download the file via WWW or UnityWebRequest. } }); }
public async void OnSuccess(Java.Lang.Object result) { if (storageRef != null) { var url = await storageRef.GetDownloadUrlAsync(); if (url != null) { await CrossCloudFirestore .Current .Instance .Collection("PEOPLE") .Document(FirebaseAuth.Instance.Uid) .UpdateAsync("ImageUrl", url); pool = true; } } }
// Retorna un link temporal que apunta directamente al archivo // con la preview image del id especificado. private async Task <string> GetFileUrlFromFirebase(string id, string imageExtension) { string reference_link = $"{firebaseBasePath}{id}.{imageExtension}"; StorageReference storage_ref = storage.GetReferenceFromUrl(reference_link); string link = ""; await storage_ref.GetDownloadUrlAsync().ContinueWith((Task <Uri> task) => { if (!task.IsFaulted && !task.IsCanceled) { link = task.Result.ToString(); } else { //debugLog.text += $"Failed to load link. Task Faulted: {task.IsFaulted} \n"; } }); return(link); }
public static void SaveItemImage(Item item) { // Create a reference for the image StorageReference imageReference = FirebaseStorage.DefaultInstance.GetReference("images").Child("items").Child(item.itemId); // Upload the image to the path (images/items/(item.itemName)) imageReference.PutFileAsync(item.itemImagePath.ToString()).ContinueWith((Task <StorageMetadata> task) => { if (task.IsCanceled || task.IsFaulted) { // Error happened Debug.Log(task.Exception.ToString()); ViewMessageOnScreen(task.Exception.ToString()); } else { // Metadata contains file metadata such as file size, content type and downloadURL StorageMetadata metadata = task.Result; Debug.Log("Finished Uploading .... "); // Gets the download url imageReference.GetDownloadUrlAsync().ContinueWith((url) => { if (url.IsCompleted) { Debug.Log("Image download url: " + url.Result.AbsoluteUri.ToString()); FirebaseDatabase.DefaultInstance.GetReference("items").Child(item.itemId).Child("itemImageDownloadUrl").SetValueAsync(url.Result.AbsoluteUri.ToString()); //FirebaseDatabase.DefaultInstance.GetReference("users").Child(Globals.userId).Child("cart").Child(item.itemName).Child("itemImageDownloadUrl").SetValueAsync(url.Result.AbsoluteUri.ToString()); item.itemImageDownloadUrl = url.Result.AbsoluteUri.ToString(); snapshotsLoaded = true; ViewMessageOnScreen("Uploaded Image ... "); //AddItemToUserCart(item, Globals.userId.ToString()); } else { Debug.Log("Image not uploaded ... "); ViewMessageOnScreen("Image not uploaded check internet connection ... "); } }); } }); }
private static void StartUrlFetch(Action completed, StorageReference reference, string firebaseUrl) { runningFetchUrlOperationCount++; reference.GetDownloadUrlAsync().ContinueWithOnMainThread(task => { if (task.IsCanceled || task.IsFaulted) { Debug.LogError($"Could not get url for: {firebaseUrl}, {task.Exception}"); } else { string url = task.Result.ToString(); SetInternalIdToStorageUrlMapping(firebaseUrl, url); } runningFetchUrlOperationCount--; if (runningFetchUrlOperationCount <= 0) { completed(); } }); }
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; }); } }
public async Task <string> GetDownloadUrlAsync() { var uri = await _wrapped.GetDownloadUrlAsync(); return(uri.ToString()); }
public async Task <string> GetDownloadUrlAsync() { var uri = await _wrapped.GetDownloadUrlAsync(); return(uri.AbsoluteString); }