Ejemplo n.º 1
0
 public StorageUploader(IServiceProvider serviceProvider, TempStream tempStream, ICacheNotify <MigrationProgress> cacheMigrationNotify, DistributedTaskQueueOptionsManager options)
 {
     ServiceProvider      = serviceProvider;
     TempStream           = tempStream;
     CacheMigrationNotify = cacheMigrationNotify;
     Queue = options.Get(nameof(StorageUploader));
 }
Ejemplo n.º 2
0
        private const int BufferSize = 2048;//NOTE: set to 2048 to fit in minimum tcp window

        public static Stream IronReadStream(this IDataStore store, TempStream tempStream, string domain, string path, int tryCount)
        {
            var ms = tempStream.Create();

            IronReadToStream(store, domain, path, tryCount, ms);
            ms.Seek(0, SeekOrigin.Begin);
            return(ms);
        }
Ejemplo n.º 3
0
 public CrossModuleTransferUtility(
     IOptionsMonitor <ILog> option,
     TempStream tempStream,
     TempPath tempPath,
     IDataStore source,
     IDataStore destination)
 {
     Log                = option.Get("ASC.CrossModuleTransferUtility");
     Option             = option;
     TempStream         = tempStream;
     TempPath           = tempPath;
     this.source        = source ?? throw new ArgumentNullException("source");
     this.destination   = destination ?? throw new ArgumentNullException("destination");
     maxChunkUploadSize = 10 * 1024 * 1024;
     chunksize          = 5 * 1024 * 1024;
 }
Ejemplo n.º 4
0
        public BaseStorage(
            TempStream tempStream,
            TenantManager tenantManager,
            PathUtils pathUtils,
            EmailValidationKeyProvider emailValidationKeyProvider,
            IHttpContextAccessor httpContextAccessor,
            IOptionsMonitor<ILog> options)
        {

            TempStream = tempStream;
            TenantManager = tenantManager;
            PathUtils = pathUtils;
            EmailValidationKeyProvider = emailValidationKeyProvider;
            Options = options;
            Log = options.CurrentValue;
            HttpContextAccessor = httpContextAccessor;
        }
Ejemplo n.º 5
0
        ///<summary>
        /// Copy from one module to another. Can copy from s3 to disk and vice versa
        ///</summary>
        ///<param name="srcStore"></param>
        ///<param name="srcDomain"></param>
        ///<param name="srcFilename"></param>
        ///<param name="dstStore"></param>
        ///<param name="dstDomain"></param>
        ///<param name="dstFilename"></param>
        ///<returns></returns>
        ///<exception cref="ArgumentNullException"></exception>
        public static Uri CrossCopy(IDataStore srcStore, string srcDomain, string srcFilename, IDataStore dstStore,
                                    string dstDomain, string dstFilename)
        {
            if (srcStore == null)
            {
                throw new ArgumentNullException("srcStore");
            }
            if (srcDomain == null)
            {
                throw new ArgumentNullException("srcDomain");
            }
            if (srcFilename == null)
            {
                throw new ArgumentNullException("srcFilename");
            }
            if (dstStore == null)
            {
                throw new ArgumentNullException("dstStore");
            }
            if (dstDomain == null)
            {
                throw new ArgumentNullException("dstDomain");
            }
            if (dstFilename == null)
            {
                throw new ArgumentNullException("dstFilename");
            }
            //Read contents
            using (Stream srcStream = srcStore.GetReadStream(srcDomain, srcFilename))
            {
                using (var memoryStream = TempStream.Create())
                {
                    //Copy
                    var buffer = new byte[4096];
                    int readed;
                    while ((readed = srcStream.Read(buffer, 0, 4096)) != 0)
                    {
                        memoryStream.Write(buffer, 0, readed);
                    }

                    memoryStream.Position = 0;
                    return(dstStore.Save(dstDomain, dstFilename, memoryStream));
                }
            }
        }
Ejemplo n.º 6
0
        private bool GetStream(Stream stream, out Stream memstream)
        {
            memstream = TempStream.Create();
            var       total = 0;
            int       readed;
            const int portion = 2048;
            var       buffer  = new byte[portion];

            while ((readed = stream.Read(buffer, 0, portion)) > 0)
            {
                memstream.Write(buffer, 0, readed);
                total += readed;
                if (total >= chunksize)
                {
                    break;
                }
            }

            return(total > 0);
        }
Ejemplo n.º 7
0
        public MigrateOperation(
            IServiceProvider serviceProvider,
            ICacheNotify <MigrationProgress> cacheMigrationNotify,
            string id,
            int tenantId,
            StorageSettings settings,
            StorageFactoryConfig storageFactoryConfig,
            TempStream tempStream)
        {
            Id     = id;
            Status = DistributedTaskStatus.Created;

            ServiceProvider      = serviceProvider;
            CacheMigrationNotify = cacheMigrationNotify;
            this.tenantId        = tenantId;
            this.settings        = settings;
            StorageFactoryConfig = storageFactoryConfig;
            TempStream           = tempStream;
            Modules   = storageFactoryConfig.GetModuleList(ConfigPath, true);
            StepCount = Modules.Count();
            Log       = serviceProvider.GetService <IOptionsMonitor <ILog> >().CurrentValue;
        }