GetBlobInfo() public method

public GetBlobInfo ( ) : IRBlobInfo
return IRBlobInfo
Ejemplo n.º 1
0
        /// <summary>
        /// Sends file to R-Host by creating a new blob. This method adds the blob for clean up by default.
        /// </summary>
        /// <param name="filePath">Path to the file to be sent to R-Host.</param>
        /// <param name="doCleanUp">
        /// true to add blob created upon transfer for cleanup on dispose, false to ignore it after transfer.
        /// </param>
        public async Task <IRBlobInfo> SendFileAsync(string filePath, bool doCleanUp, IProgress <long> progress, CancellationToken cancellationToken)
        {
            IRBlobInfo blob = null;

            using (RBlobStream blobStream = await RBlobStream.CreateAsync(_blobService))
                using (Stream fileStream = _fs.FileOpen(filePath, FileMode.Open)){
                    await fileStream.CopyToAsync(blobStream, progress, cancellationToken);

                    blob = blobStream.GetBlobInfo();
                }

            if (doCleanUp)
            {
                _cleanup.Add(blob);
            }
            return(blob);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Sends a block of data to R-Host by creating a new blob. This method adds the blob for clean
        /// up by default.
        /// </summary>
        /// <param name="data">Block of data to be sent.</param>
        /// <param name="doCleanUp">
        /// true to add blob created upon transfer for cleanup on dispose, false to ignore it after transfer.
        /// </param>
        public async Task <IRBlobInfo> SendBytesAsync(byte[] data, bool doCleanUp, IProgress <long> progress, CancellationToken cancellationToken)
        {
            IRBlobInfo blob = null;

            using (RBlobStream blobStream = await RBlobStream.CreateAsync(_blobService))
                using (Stream ms = new MemoryStream(data)) {
                    await ms.CopyToAsync(blobStream, progress, cancellationToken);

                    blob = blobStream.GetBlobInfo();
                }

            if (doCleanUp)
            {
                _cleanup.Add(blob);
            }
            return(blob);
        }