/// <summary>
        /// Retrieve a read-only stream over an object that has been stored.
        /// </summary>
        /// <param name="key">The object key.</param>
        /// <param name="callbacks">CallbackMethods object containing callback methods.</param>
        /// <param name="data">Read-only stream.</param>
        /// <returns>True if successful.</returns>
        public bool TryGetStream(string key, DedupeCallbacks callbacks, out DedupeStream data)
        {
            if (String.IsNullOrEmpty(key))
            {
                throw new ArgumentNullException(nameof(key));
            }
            if (callbacks == null)
            {
                throw new ArgumentNullException(nameof(callbacks));
            }
            if (callbacks.ReadChunk == null)
            {
                throw new ArgumentException("ReadChunk callback must be specified.");
            }
            key = DedupeCommon.SanitizeString(key);

            data = null;

            try
            {
                data = GetStream(key, callbacks);
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Exemple #2
0
        /// <summary>
        /// Retrieve a read-only stream over an object that has been stored.
        /// </summary>
        /// <param name="objectName">The name of the object.</param>
        /// <param name="callbacks">CallbackMethods object containing callback methods.</param>
        /// <param name="stream">Read-only stream.</param>
        /// <returns>True if successful.</returns>
        public bool RetrieveObjectStream(string objectName, CallbackMethods callbacks, out DedupeStream stream)
        {
            stream = null;
            if (String.IsNullOrEmpty(objectName))
            {
                throw new ArgumentNullException(nameof(objectName));
            }
            if (callbacks == null)
            {
                throw new ArgumentNullException(nameof(callbacks));
            }
            if (callbacks.ReadChunk == null)
            {
                throw new ArgumentException("ReadChunk callback must be specified.");
            }
            objectName = DedupeCommon.SanitizeString(objectName);

            if (!RetrieveObjectMetadata(objectName, out ObjectMetadata md))
            {
                return(false);
            }

            stream = new DedupeStream(md, _Database, callbacks);
            return(true);
        }
        /// <summary>
        /// Retrieve a read-only stream over an object that has been stored.
        /// </summary>
        /// <param name="key">The object key.</param>
        /// <param name="data">Read-only stream.</param>
        /// <returns>True if successful.</returns>
        public bool TryGetStream(string key, out DedupeStream data)
        {
            if (String.IsNullOrEmpty(key))
            {
                throw new ArgumentNullException(nameof(key));
            }
            key = DedupeCommon.SanitizeString(key);

            data = null;

            try
            {
                data = GetStream(key, Callbacks);
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Exemple #4
0
 /// <summary>
 /// Retrieve a read-only stream over an object that has been stored.
 /// </summary>
 /// <param name="objectName">The name of the object.</param>
 /// <param name="stream">Read-only stream.</param>
 /// <returns>True if successful.</returns>
 public bool RetrieveObjectStream(string objectName, out DedupeStream stream)
 {
     return(RetrieveObjectStream(objectName, Callbacks, out stream));
 }