private SynchronizingFileStream(ITransactionalStorage transactionalStorage, string fileName,
										StorageStreamAccess storageStreamAccess, RavenJObject metadata,
										IndexStorage indexStorage, StorageOperationsTask operations)
			: base(transactionalStorage, fileName, storageStreamAccess, metadata, indexStorage, operations)
		{
		    md5Hasher = Encryptor.Current.CreateHash();
		}
示例#2
0
		protected StorageStream(ITransactionalStorage transactionalStorage, string fileName,
								StorageStreamAccess storageStreamAccess,
								RavenJObject metadata, IndexStorage indexStorage, StorageOperationsTask operations)
		{
			TransactionalStorage = transactionalStorage;
			StorageStreamAccess = storageStreamAccess;
			Name = fileName;

			switch (storageStreamAccess)
			{
				case StorageStreamAccess.Read:
					TransactionalStorage.Batch(accessor => fileHeader = accessor.ReadFile(fileName));
					if (fileHeader.TotalSize == null)
					{
						throw new FileNotFoundException("File is not uploaded yet");
					}
					Metadata = fileHeader.Metadata;
					Seek(0, SeekOrigin.Begin);
					break;
				case StorageStreamAccess.CreateAndWrite:
					TransactionalStorage.Batch(accessor =>
					{
						operations.IndicateFileToDelete(fileName);
						accessor.PutFile(fileName, null, metadata);
						indexStorage.Index(fileName, metadata);
					});
					Metadata = metadata;
					break;
				default:
					throw new ArgumentOutOfRangeException("storageStreamAccess", storageStreamAccess, "Unknown value");
			}
		}
 private SynchronizingFileStream(ITransactionalStorage transactionalStorage, string fileName,
                                 StorageStreamAccess storageStreamAccess, RavenJObject metadata,
                                 IndexStorage indexStorage, StorageOperationsTask operations)
     : base(transactionalStorage, fileName, storageStreamAccess, metadata, indexStorage, operations)
 {
     md5Hasher = Encryptor.Current.CreateHash();
 }
		private SynchronizingFileStream(ITransactionalStorage transactionalStorage, string fileName,
										StorageStreamAccess storageStreamAccess, NameValueCollection metadata,
										IndexStorage indexStorage, StorageOperationsTask operations)
			: base(transactionalStorage, fileName, storageStreamAccess, metadata, indexStorage, operations)
		{
			md5Hasher = new MD5CryptoServiceProvider();
		}
示例#5
0
        protected StorageStream(ITransactionalStorage transactionalStorage, string fileName,
                                StorageStreamAccess storageStreamAccess,
                                RavenJObject metadata, IndexStorage indexStorage, StorageOperationsTask operations)
        {
            TransactionalStorage = transactionalStorage;
            StorageStreamAccess  = storageStreamAccess;
            Name = fileName;

            switch (storageStreamAccess)
            {
            case StorageStreamAccess.Read:
                TransactionalStorage.Batch(accessor => fileHeader = accessor.ReadFile(fileName));
                if (fileHeader.TotalSize == null)
                {
                    throw new FileNotFoundException("File is not uploaded yet");
                }
                Metadata = fileHeader.Metadata;
                Seek(0, SeekOrigin.Begin);
                break;

            case StorageStreamAccess.CreateAndWrite:
                TransactionalStorage.Batch(accessor =>
                {
                    operations.IndicateFileToDelete(fileName);
                    accessor.PutFile(fileName, null, metadata);
                    indexStorage.Index(fileName, metadata);
                });
                Metadata = metadata;
                break;

            default:
                throw new ArgumentOutOfRangeException("storageStreamAccess", storageStreamAccess, "Unknown value");
            }
        }
示例#6
0
        protected StorageStream(RavenFileSystem fileSystem, ITransactionalStorage storage, string fileName, RavenJObject metadata, StorageStreamAccess storageStreamAccess)
        {
            this.fileSystem = fileSystem;
            this.storage    = storage;

            StorageStreamAccess = storageStreamAccess;
            Name = fileName;

            switch (storageStreamAccess)
            {
            case StorageStreamAccess.Read:
                storage.Batch(accessor => fileHeader = accessor.ReadFile(fileName));
                if (fileHeader.TotalSize == null)
                {
                    throw new FileNotFoundException("File is not uploaded yet");
                }
                Metadata = fileHeader.Metadata;
                Seek(0, SeekOrigin.Begin);
                break;

            case StorageStreamAccess.CreateAndWrite:

                if (this.fileSystem == null)
                {
                    throw new ArgumentNullException("fileSystem");
                }

                storage.Batch(accessor =>
                {
                    using (fileSystem.DisableAllTriggersForCurrentThread())
                    {
                        fileSystem.Files.IndicateFileToDelete(fileName, null);
                    }

                    var putResult = accessor.PutFile(fileName, null, metadata);
                    fileSystem.Search.Index(fileName, metadata, putResult.Etag);
                });
                Metadata = metadata;
                break;

            default:
                throw new ArgumentOutOfRangeException("storageStreamAccess", storageStreamAccess, "Unknown value");
            }
        }
示例#7
0
        protected StorageStream(RavenFileSystem fileSystem, ITransactionalStorage storage, string fileName, RavenJObject metadata, StorageStreamAccess storageStreamAccess)
        {
            this.fileSystem = fileSystem;
            this.storage = storage;

            StorageStreamAccess = storageStreamAccess;
            Name = fileName;

            switch (storageStreamAccess)
            {
                case StorageStreamAccess.Read:
                    storage.Batch(accessor => fileHeader = accessor.ReadFile(fileName));
                    if (fileHeader.TotalSize == null)
                    {
                        throw new FileNotFoundException("File is not uploaded yet");
                    }
                    Metadata = fileHeader.Metadata;
                    Seek(0, SeekOrigin.Begin);
                    break;
                case StorageStreamAccess.CreateAndWrite:

                    if (this.fileSystem == null)
                        throw new ArgumentNullException("fileSystem");

                    storage.Batch(accessor =>
                    {
                        using (fileSystem.DisableAllTriggersForCurrentThread())
                        {
                            fileSystem.Files.IndicateFileToDelete(fileName, null);
                        }

                        var putResult = accessor.PutFile(fileName, null, metadata);
                        fileSystem.Search.Index(fileName, metadata, putResult.Etag);
                    });
                    Metadata = metadata;
                    break;
                default:
                    throw new ArgumentOutOfRangeException("storageStreamAccess", storageStreamAccess, "Unknown value");
            }
        }
 private SynchronizingFileStream(RavenFileSystem fileSystem, string fileName,
                                 RavenJObject metadata, StorageStreamAccess storageStreamAccess)
     : base(fileSystem, fileSystem.Storage, fileName, metadata, storageStreamAccess)
 {
     md5Hasher = Encryptor.Current.CreateHash();
 }
示例#9
0
		private SynchronizingFileStream(RavenFileSystem fileSystem, string fileName,
										RavenJObject metadata, StorageStreamAccess storageStreamAccess)
			: base(fileSystem, fileSystem.Storage, fileName, metadata, storageStreamAccess)
		{
		    md5Hasher = Encryptor.Current.CreateHash();
		}