Ejemplo n.º 1
0
 public GeoLocationWrite(AppSettings appSettings, IExifTool exifTool, ISelectorStorage selectorStorage, IConsole console)
 {
     _exifTool         = exifTool;
     _appSettings      = appSettings;
     _thumbnailStorage = selectorStorage.Get(SelectorStorage.StorageServices.Thumbnail);
     _iStorage         = selectorStorage.Get(SelectorStorage.StorageServices.SubPath);
     _console          = console;
 }
Ejemplo n.º 2
0
 public ThumbnailGenerationController(ISelectorStorage selectorStorage,
                                      IQuery query, IWebLogger logger, IWebSocketConnectionsService connectionsService)
 {
     _selectorStorage    = selectorStorage;
     _query              = query;
     _logger             = logger;
     _connectionsService = connectionsService;
 }
Ejemplo n.º 3
0
 public MetaThumbnailCommandLineHelper(ISelectorStorage selectorStorage, AppSettings appSettings,
                                       IConsole console, IMetaExifThumbnailService metaExifThumbnailService)
 {
     _selectorStorage          = selectorStorage;
     _appSettings              = appSettings;
     _metaExifThumbnailService = metaExifThumbnailService;
     _console = console;
 }
Ejemplo n.º 4
0
 public UpdateImportTransformations(IWebLogger logger,
                                    IExifTool exifTool, ISelectorStorage selectorStorage, AppSettings appSettings)
 {
     _logger           = logger;
     _exifTool         = exifTool;
     _subPathStorage   = selectorStorage.Get(SelectorStorage.StorageServices.SubPath);
     _thumbnailStorage = selectorStorage.Get(SelectorStorage.StorageServices.Thumbnail);
     _appSettings      = appSettings;
 }
Ejemplo n.º 5
0
 public WebFtpCli(AppSettings appSettings, ISelectorStorage selectorStorage, IConsole console,
                  IFtpWebRequestFactory webRequestFactory)
 {
     _appSettings         = appSettings;
     _console             = console;
     _argsHelper          = new ArgsHelper(_appSettings, console);
     _hostStorageProvider = selectorStorage.Get(SelectorStorage.StorageServices.HostFilesystem);
     _webRequestFactory   = webRequestFactory;
 }
Ejemplo n.º 6
0
 public Synchronize(AppSettings appSettings, IQuery query, ISelectorStorage selectorStorage, IWebLogger logger, IMemoryCache memoryCache = null)
 {
     _console         = new ConsoleWrapper();
     _subPathStorage  = selectorStorage.Get(SelectorStorage.StorageServices.SubPath);
     _syncSingleFile  = new SyncSingleFile(appSettings, query, _subPathStorage, logger);
     _syncRemove      = new SyncRemove(appSettings, query, memoryCache, logger);
     _syncFolder      = new SyncFolder(appSettings, query, selectorStorage, _console, logger, memoryCache);
     _syncIgnoreCheck = new SyncIgnoreCheck(appSettings, _console);
 }
Ejemplo n.º 7
0
 public ExportService(IQuery query, AppSettings appSettings,
                      ISelectorStorage selectorStorage, IWebLogger logger)
 {
     _appSettings           = appSettings;
     _query                 = query;
     _iStorage              = selectorStorage.Get(SelectorStorage.StorageServices.SubPath);
     _thumbnailStorage      = selectorStorage.Get(SelectorStorage.StorageServices.Thumbnail);
     _hostFileSystemStorage = selectorStorage.Get(SelectorStorage.StorageServices.HostFilesystem);
     _logger                = logger;
 }
Ejemplo n.º 8
0
 /// <summary>Replace meta content</summary>
 /// <param name="query">Starsky IQuery interface to do calls on the database</param>
 /// <param name="appSettings">Settings of the application</param>
 /// <param name="selectorStorage">storage abstraction</param>
 /// <param name="logger">web logger</param>
 public MetaReplaceService(IQuery query, AppSettings appSettings, ISelectorStorage selectorStorage, IWebLogger logger)
 {
     _query       = query;
     _appSettings = appSettings;
     if (selectorStorage != null)
     {
         _iStorage = selectorStorage.Get(SelectorStorage.StorageServices.SubPath);
     }
     _logger = logger;
 }
Ejemplo n.º 9
0
 public GeoController(IUpdateBackgroundTaskQueue queue,
                      ISelectorStorage selectorStorage,
                      IMemoryCache memoryCache, IWebLogger logger, IServiceScopeFactory serviceScopeFactory)
 {
     _bgTaskQueue         = queue;
     _iStorage            = selectorStorage.Get(SelectorStorage.StorageServices.SubPath);
     _cache               = memoryCache;
     _serviceScopeFactory = serviceScopeFactory;
     _logger              = logger;
 }
Ejemplo n.º 10
0
 public ThumbnailCli(AppSettings appSettings,
                     IConsole console, IThumbnailService thumbnailService, IThumbnailCleaner thumbnailCleaner,
                     ISelectorStorage selectorStorage)
 {
     _appSettings      = appSettings;
     _thumbnailService = thumbnailService;
     _console          = console;
     _thumbnailCleaner = thumbnailCleaner;
     _selectorStorage  = selectorStorage;
 }
Ejemplo n.º 11
0
 public OverlayImage(ISelectorStorage selectorStorage, AppSettings appSettings)
 {
     _appSettings = appSettings;
     if (selectorStorage == null)
     {
         return;
     }
     _iStorage         = selectorStorage.Get(SelectorStorage.StorageServices.SubPath);
     _thumbnailStorage = selectorStorage.Get(SelectorStorage.StorageServices.Thumbnail);
     _hostFileSystem   = selectorStorage.Get(SelectorStorage.StorageServices.HostFilesystem);
 }
Ejemplo n.º 12
0
 public CopyPublishedContent(AppSettings appSettings, ToCreateSubfolder toCreateSubfolder,
                             ISelectorStorage selectorStorage)
 {
     _appSettings       = appSettings;
     _toCreateSubfolder = toCreateSubfolder;
     if (selectorStorage == null)
     {
         return;
     }
     _hostStorage = selectorStorage.Get(SelectorStorage.StorageServices.HostFilesystem);
 }
Ejemplo n.º 13
0
 public PublishCli(ISelectorStorage storageSelector, IPublishPreflight publishPreflight,
                   IWebHtmlPublishService publishService, AppSettings appSettings, IConsole console)
 {
     _publishPreflight      = publishPreflight;
     _publishService        = publishService;
     _appSettings           = appSettings;
     _console               = console;
     _argsHelper            = new ArgsHelper(appSettings, console);
     _hostFileSystemStorage = storageSelector.Get(SelectorStorage.StorageServices.HostFilesystem);
     _subPathStorage        = storageSelector.Get(SelectorStorage.StorageServices.SubPath);
 }
Ejemplo n.º 14
0
 public MetaExifThumbnailService(AppSettings appSettings, ISelectorStorage selectorStorage,
                                 IOffsetDataMetaExifThumbnail offsetDataMetaExifThumbnail,
                                 IWriteMetaThumbnailService writeMetaThumbnailService, IWebLogger logger)
 {
     _appSettings                 = appSettings;
     _iStorage                    = selectorStorage.Get(SelectorStorage.StorageServices.SubPath);
     _thumbnailStorage            = selectorStorage.Get(SelectorStorage.StorageServices.Thumbnail);
     _offsetDataMetaExifThumbnail = offsetDataMetaExifThumbnail;
     _writeMetaThumbnailService   = writeMetaThumbnailService;
     _logger = logger;
 }
Ejemplo n.º 15
0
 public OverlayImageTest()
 {
     _storage = new FakeIStorage(new List <string> {
         "/"
     },
                                 new List <string> {
         "/test.jpg"
     }, new List <byte[]> {
         CreateAnImage.Bytes
     });
     _selectorStorage = new FakeSelectorStorage(_storage);
 }
Ejemplo n.º 16
0
 public SyncFolder(AppSettings appSettings, IQuery query,
                   ISelectorStorage selectorStorage, IConsole console, IWebLogger logger, IMemoryCache memoryCache)
 {
     _subPathStorage     = selectorStorage.Get(SelectorStorage.StorageServices.SubPath);
     _appSettings        = appSettings;
     _setupDatabaseTypes = new SetupDatabaseTypes(appSettings);
     _query           = query;
     _console         = console;
     _duplicate       = new Duplicate(_query);
     _logger          = logger;
     _memoryCache     = memoryCache;
     _syncIgnoreCheck = new SyncIgnoreCheck(appSettings, console);
 }
Ejemplo n.º 17
0
 public GeoBackgroundTask(AppSettings appSettings, ISelectorStorage selectorStorage,
                          IGeoLocationWrite geoLocationWrite, IMemoryCache memoryCache,
                          IWebLogger logger, IGeoReverseLookup geoReverseLookup)
 {
     _appSettings      = appSettings;
     _iStorage         = selectorStorage.Get(SelectorStorage.StorageServices.SubPath);
     _thumbnailStorage = selectorStorage.Get(SelectorStorage.StorageServices.Thumbnail);
     _readMeta         = new ReadMeta(_iStorage);
     _geoLocationWrite = geoLocationWrite;
     _logger           = logger;
     _geoIndexGpx      = new GeoIndexGpx(_appSettings, _iStorage, memoryCache);
     _geoReverseLookup = geoReverseLookup;
 }
Ejemplo n.º 18
0
 public GeoCli(IGeoReverseLookup geoReverseLookup,
               IGeoLocationWrite geoLocationWrite, ISelectorStorage selectorStorage, AppSettings appSettings, IConsole console,
               IGeoFileDownload geoFileDownload, IExifToolDownload exifToolDownload)
 {
     _geoReverseLookup = geoReverseLookup;
     _geoLocationWrite = geoLocationWrite;
     _iStorage         = selectorStorage.Get(SelectorStorage.StorageServices.SubPath);
     _thumbnailStorage = selectorStorage.Get(SelectorStorage.StorageServices.Thumbnail);
     _readMeta         = new ReadMeta(_iStorage, appSettings);
     _appSettings      = appSettings;
     _console          = console;
     _exifToolDownload = exifToolDownload;
     _geoFileDownload  = geoFileDownload;
 }
Ejemplo n.º 19
0
 public ImportController(IImport import, AppSettings appSettings,
                         IUpdateBackgroundTaskQueue queue,
                         IHttpClientHelper httpClientHelper, ISelectorStorage selectorStorage,
                         IServiceScopeFactory scopeFactory, IWebLogger logger)
 {
     _appSettings           = appSettings;
     _import                = import;
     _bgTaskQueue           = queue;
     _httpClientHelper      = httpClientHelper;
     _selectorStorage       = selectorStorage;
     _hostFileSystemStorage = selectorStorage.Get(SelectorStorage.StorageServices.HostFilesystem);
     _thumbnailStorage      = selectorStorage.Get(SelectorStorage.StorageServices.Thumbnail);
     _scopeFactory          = scopeFactory;
     _logger                = logger;
 }
Ejemplo n.º 20
0
 public UploadController(IImport import, AppSettings appSettings,
                         ISelectorStorage selectorStorage, IQuery query,
                         IRealtimeConnectionsService connectionsService, IWebLogger logger,
                         IMetaExifThumbnailService metaExifThumbnailService)
 {
     _appSettings              = appSettings;
     _import                   = import;
     _query                    = query;
     _selectorStorage          = selectorStorage;
     _iStorage                 = selectorStorage.Get(SelectorStorage.StorageServices.SubPath);
     _iHostStorage             = selectorStorage.Get(SelectorStorage.StorageServices.HostFilesystem);
     _connectionsService       = connectionsService;
     _logger                   = logger;
     _metaExifThumbnailService = metaExifThumbnailService;
 }
Ejemplo n.º 21
0
 public MetaUpdateService(
     IQuery query,
     IExifTool exifTool,
     ISelectorStorage selectorStorage,
     IMetaPreflight metaPreflight,
     IWebLogger logger,
     IReadMetaSubPathStorage readMetaSubPathStorage)
 {
     _query            = query;
     _exifTool         = exifTool;
     _iStorage         = selectorStorage.Get(SelectorStorage.StorageServices.SubPath);
     _thumbnailStorage = selectorStorage.Get(SelectorStorage.StorageServices.Thumbnail);
     _readMeta         = readMetaSubPathStorage;
     _metaPreflight    = metaPreflight;
     _logger           = logger;
 }
Ejemplo n.º 22
0
 public WebHtmlPublishService(IPublishPreflight publishPreflight, ISelectorStorage
                              selectorStorage, AppSettings appSettings, IExifToolHostStorage exifTool,
                              IOverlayImage overlayImage, IConsole console, IWebLogger logger)
 {
     _publishPreflight      = publishPreflight;
     _subPathStorage        = selectorStorage.Get(SelectorStorage.StorageServices.SubPath);
     _thumbnailStorage      = selectorStorage.Get(SelectorStorage.StorageServices.Thumbnail);
     _hostFileSystemStorage = selectorStorage.Get(SelectorStorage.StorageServices.HostFilesystem);
     _appSettings           = appSettings;
     _exifTool             = exifTool;
     _console              = console;
     _overlayImage         = overlayImage;
     _publishManifest      = new PublishManifest(_hostFileSystemStorage, new PlainTextFileHelper());
     _toCreateSubfolder    = new ToCreateSubfolder(_hostFileSystemStorage);
     _copyPublishedContent = new CopyPublishedContent(_appSettings, _toCreateSubfolder,
                                                      selectorStorage);
     _logger           = logger;
     _thumbnailService = new Thumbnail(_subPathStorage, _thumbnailStorage, _logger);
 }
Ejemplo n.º 23
0
 public AppSettingsController(AppSettings appSettings, ISelectorStorage selectorStorage)
 {
     _appSettings = appSettings;
     _hostStorage = selectorStorage.Get(SelectorStorage.StorageServices.HostFilesystem);
 }
Ejemplo n.º 24
0
 public SyncCli(ISynchronize synchronize, AppSettings appSettings, IConsole console, ISelectorStorage selectorStorage)
 {
     _appSettings     = appSettings;
     _console         = console;
     _synchronize     = synchronize;
     _selectorStorage = selectorStorage;
 }
Ejemplo n.º 25
0
 public FakeIImport(ISelectorStorage selectorStorage)
 {
     _selectorStorage = selectorStorage;
 }
Ejemplo n.º 26
0
 public AccountController(IUserManager userManager, AppSettings appSettings, IAntiforgery antiForgery, ISelectorStorage selectorStorage)
 {
     _userManager = userManager;
     _appSettings = appSettings;
     _antiForgery = antiForgery;
     _storageHostFullPathFilesystem = selectorStorage.Get(SelectorStorage.StorageServices.HostFilesystem);
 }
Ejemplo n.º 27
0
 public ThumbnailController(IQuery query, ISelectorStorage selectorStorage)
 {
     _query            = query;
     _iStorage         = selectorStorage.Get(SelectorStorage.StorageServices.SubPath);
     _thumbnailStorage = selectorStorage.Get(SelectorStorage.StorageServices.Thumbnail);
 }
Ejemplo n.º 28
0
 public static async Task <List <string> > StreamFile(this HttpRequest request,
                                                      AppSettings appSettings, ISelectorStorage selectorStorage)
 {
     // The Header 'filename' is for uploading on file without a form.
     return(await StreamFile(request.ContentType, request.Body, appSettings,
                             selectorStorage, HeaderFileName(request, appSettings)));
 }
Ejemplo n.º 29
0
 public PublishController(AppSettings appSettings, IPublishPreflight publishPreflight,
                          IWebHtmlPublishService publishService, IMetaInfo metaInfo, ISelectorStorage selectorStorage,
                          IUpdateBackgroundTaskQueue queue, IWebLogger webLogger)
 {
     _appSettings      = appSettings;
     _publishPreflight = publishPreflight;
     _publishService   = publishService;
     _metaInfo         = metaInfo;
     _hostStorage      = selectorStorage.Get(SelectorStorage.StorageServices.HostFilesystem);
     _bgTaskQueue      = queue;
     _webLogger        = webLogger;
 }
Ejemplo n.º 30
0
        public static async Task <List <string> > StreamFile(string contentType, Stream requestBody, AppSettings appSettings,
                                                             ISelectorStorage selectorStorage, string headerFileName = null)
        {
            // headerFileName is for uploading on a single file without a multi part form.

            // fallback
            if (headerFileName == null)
            {
                headerFileName = Base32.Encode(FileHash.GenerateRandomBytes(8)) + ".unknown";
            }

            var tempPaths = new List <string>();

            if (!MultipartRequestHelper.IsMultipartContentType(contentType))
            {
                if (contentType != "image/jpeg" && contentType != "application/octet-stream")
                {
                    throw new FileLoadException($"Expected a multipart request, but got {contentType}; add the header 'content-type' ");
                }

                var randomFolderName = "stream_" +
                                       Base32.Encode(FileHash.GenerateRandomBytes(4));
                var fullFilePath = Path.Combine(appSettings.TempFolder, randomFolderName, headerFileName);

                // Write to disk
                var hostFileSystemStorage =
                    selectorStorage.Get(SelectorStorage.StorageServices
                                        .HostFilesystem);
                hostFileSystemStorage.CreateDirectory(Path.Combine(appSettings.TempFolder, randomFolderName));
                await hostFileSystemStorage
                .WriteStreamAsync(requestBody, fullFilePath);

                tempPaths.Add(fullFilePath);

                return(tempPaths);
            }

            // Used to accumulate all the form url encoded key value pairs in the
            // request.

            var boundary = MultipartRequestHelper.GetBoundary(MediaTypeHeaderValue.Parse(contentType),
                                                              DefaultFormOptions.MultipartBoundaryLengthLimit);
            var reader = new MultipartReader(boundary, requestBody);

            var section = await reader.ReadNextSectionAsync();

            while (section != null)
            {
                var hasContentDispositionHeader = ContentDispositionHeaderValue.TryParse(
                    section.ContentDisposition, out var contentDisposition);

                if (hasContentDispositionHeader && MultipartRequestHelper.HasFileContentDisposition(contentDisposition))
                {
                    var sourceFileName = contentDisposition.FileName.ToString().Replace("\"", string.Empty);
                    var inputExtension = Path.GetExtension(sourceFileName).Replace("\n", string.Empty);

                    var tempHash = appSettings.GenerateSlug(Path.GetFileNameWithoutExtension(sourceFileName),
                                                            true, false); // underscore allowed
                    var randomFolderName = "stream_" +
                                           Base32.Encode(FileHash.GenerateRandomBytes(4));
                    var fullFilePath = Path.Combine(appSettings.TempFolder, randomFolderName, tempHash + inputExtension);
                    tempPaths.Add(fullFilePath);

                    var hostFileSystemStorage =
                        selectorStorage.Get(SelectorStorage.StorageServices
                                            .HostFilesystem);
                    hostFileSystemStorage.CreateDirectory(Path.Combine(appSettings.TempFolder, randomFolderName));
                    await hostFileSystemStorage
                    .WriteStreamAsync(section.Body, fullFilePath);
                }

                // Drains any remaining section body that has not been consumed and
                // reads the headers for the next section.
                section = await reader.ReadNextSectionAsync();
            }

            return(tempPaths);
        }