Exemple #1
0
        /// <summary>
        /// Updates the specified file.
        /// </summary>
        /// <param name="file">The file.</param>
        /// <param name="stream">The binary stream.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken" /> used to propagate notifications that the operation should be canceled.</param>
        /// <returns></returns>
        public async Task UpdateAsync(File file, Stream stream, CancellationToken cancellationToken)
        {
            // use file guid instead name
            var queryOptions = new FileQueryOptions()
            {
                Type = file.Type
            };

            queryOptions.DocumentIds.Add(file.DocumentId);
            var filesToRemove = await FileStore.FindAsync(queryOptions, cancellationToken);

            foreach (var fileToRemove in filesToRemove)
            {
                BinaryProvider.Delete(fileToRemove.Reference);
            }

            await FileStore.UpdateAsync(file, cancellationToken);

            var reference = BinaryProvider.InitUpload(file.Id.ToString(CultureInfo.CurrentCulture));
            await FileStore.InitAsync(file.Id, BinaryProvider.AssemblyQualifiedName, reference, cancellationToken);

            await BinaryProvider.FinalizeUploadAsync(reference, stream, cancellationToken);

            await FileStore.FinalizeAsync(file.Id, cancellationToken);
        }
Exemple #2
0
        /// <summary>
        /// Gets the file with the specified options.
        /// </summary>
        /// <param name="options">The query options.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken" /> used to propagate notifications that the operation should be canceled.</param>
        /// <returns>
        /// The file objects.
        /// </returns>
        public async Task <IList <File> > FindAsync(FileQueryOptions options, CancellationToken cancellationToken)
        {
            var files = await FileStore.FindAsync(options, cancellationToken);

            return(files);
        }
Exemple #3
0
 /// <summary>
 /// Gets the document with the specified options.
 /// </summary>
 /// <param name="options">The query options.</param>
 /// <param name="cancellationToken">The <see cref="CancellationToken" /> used to propagate notifications that the operation should be canceled.</param>
 /// <returns>
 /// The file objects.
 /// </returns>
 public abstract Task <IList <File> > FindAsync(FileQueryOptions options, CancellationToken cancellationToken);