private IStorageTransferTask PutData(NSData data, IStorageMetadata metadata = null)
        {
            var wrapper = new StorageTransferTaskWrapper <StorageUploadTask, NativeStorageMetadata>();

            wrapper.TransferTask = _wrapped.PutData(data, metadata?.ToNative(), (x, e) => wrapper.CompletionHandler(x, e));
            return(wrapper);
        }
        // Upload image to Firebase Storage.
        void SaveImageToStorage(string imageId, UIImage image)
        {
            var imageMetadata = new StorageMetadata {
                ContentType = "image/jpeg"
            };
            StorageReference storageImageNode = storageImagesNode.GetChild(imageId);

            storageImageNode.PutData(image.AsJPEG(), imageMetadata, (metadata, error) => {
                if (error != null)
                {
                    Console.WriteLine(error.LocalizedDescription);
                }
            });
        }
        public Task PutBytesAsync(byte[] bytes, MetadataChange?metadata = null, IProgress <IUploadState>?progress = null, CancellationToken cancellationToken = default, PauseToken pauseToken = default)
        {
            if (bytes == null)
            {
                throw new ArgumentNullException(nameof(bytes));
            }

            var data = NSData.FromArray(bytes);
            var tcs  = new TaskCompletionSource <bool>();

            var uploadTask = _storageReference.PutData(data, metadata?.ToStorageMetadata(), (storageMetadata, error) =>
            {
                if (error != null)
                {
                    tcs.SetException(ExceptionMapper.Map(new NSErrorException(error)));
                }
                else
                {
                    tcs.SetResult(true);
                }
            });

            if (progress != null)
            {
                uploadTask.ObserveStatus(StorageTaskStatus.Progress, snapshot => progress.Report(new StorageTaskSnapshotWrapper(snapshot)));
            }

            if (cancellationToken != default)
            {
                cancellationToken.Register(uploadTask.Cancel);
            }

            if (pauseToken != default)
            {
                pauseToken.SetStorageTask(new StorageUploadTaskWrapper(uploadTask));
            }

            return(tcs.Task);
        }