public override int Read(byte[] buffer, int offset, int count)
        {
            int received = 0;

            var downloadResult = SWIG.storj_uplink.download_object(_bucket._projectRef, _bucket.Name, _objectName, new SWIG.DownloadOptions()
            {
                length = count, offset = Position
            });

            if (downloadResult.error != null && !string.IsNullOrEmpty(downloadResult.error.message))
            {
                throw new EndOfStreamException(downloadResult.error.message);
            }

            using (var download = new DownloadOperation(downloadResult, count, _objectName))
            {
                download.StartDownloadAsync().Wait();

                Buffer.BlockCopy(download.DownloadedBytes, 0, buffer, offset, (int)download.BytesReceived);

                received = (int)download.BytesReceived;
            }

            return(received);
        }
        public DownloadStream(Bucket bucket, int totalBytes, string objectName, Access access) //TODO: better access-handling
        {
            string error;

            _length     = totalBytes;
            _bucket     = bucket;
            _objectName = objectName;
            _access     = access;

            _downloadResult = SWIG.storj_uplink.download_object(_access._project, bucket.Name, objectName, null); //TODO: make DownloadOptions available to caller
            _download       = new DownloadOperation(_downloadResult, totalBytes, objectName);
            if (!_download.Running && !_download.Completed && !_download.Cancelled && !_download.Failed)
            {
                _download.StartDownloadAsync();
            }
        }