private void Btn_Click(object sender, EventArgs e) { //upload to firebase storage for (int i = 0; i < 5; i++) { StorageReference oneRef = imagesRef.Child("one" + i + ".png"); Bitmap bitmap = BitmapFactory.DecodeResource(this.Resources, Resource.Drawable.one); MemoryStream stream = new MemoryStream(); bitmap.Compress(Bitmap.CompressFormat.Png, 100, stream); byte[] data = stream.ToArray(); UploadTask uploadtask = oneRef.PutBytes(data); uploadtask.AddOnSuccessListener(this); uploadtask.AddOnFailureListener(this); } }
/// <summary> /// Encapsulate Card into a single file for uploading and sharing to Firebase /// </summary> private void uploadCardMedia(StorageReference sr_cardMedias, Card card) { // Upload media to cloud foreach (AbMediaContent media in card.mediaList) { string mediaFileName = Path.GetFileName(media.filePath); StorageReference sr_curCardMedia = sr_cardMedias.Child(mediaFileName); FileStream fs = new FileStream(media.filePath, FileMode.Open); //StorageMetadata metadata = new StorageMetadata.Builder() // .SetCustomMetadata("MediaContentType", media.mediaType.ToString()).Build(); UploadTask uploadTask = sr_curCardMedia.PutStream(fs); UploadListener uploadListener = new UploadListener(fs); uploadTask.AddOnFailureListener(uploadListener); uploadTask.AddOnSuccessListener(uploadListener); } // TODO add upload failure and success handling? }