Ejemplo n.º 1
0
        public IActionResult Info(string f, bool collections = true)
        {
            var inputFilePaths = PathHelper.SplitInputFilePaths(f).ToList();

            var fileIndexResultsList = _metaInfo.GetInfo(inputFilePaths, collections);

            // returns read only
            if (fileIndexResultsList.All(p => p.Status == FileIndexItem.ExifStatus.ReadOnly))
            {
                Response.StatusCode = 203; // is readonly
                return(Json(fileIndexResultsList));
            }

            // When all items are not found
            if (fileIndexResultsList.All(p => (p.Status != FileIndexItem.ExifStatus.Ok && p.Status != FileIndexItem.ExifStatus.Deleted)))
            {
                return(NotFound(fileIndexResultsList));
            }

            return(Json(fileIndexResultsList));
        }
Ejemplo n.º 2
0
        public IActionResult PublishCreate(string f, string itemName,
                                           string publishProfileName, bool force = false)
        {
            _webLogger.LogInformation($"[/api/publish/create] Press publish: {itemName} {f} {DateTime.UtcNow}");
            var inputFilePaths = PathHelper.SplitInputFilePaths(f).ToList();
            var info           = _metaInfo.GetInfo(inputFilePaths, false);

            if (info.All(p => p.Status != FileIndexItem.ExifStatus.Ok && p.Status != FileIndexItem.ExifStatus.ReadOnly))
            {
                return(NotFound(info));
            }

            var slugItemName = _appSettings.GenerateSlug(itemName, true);
            var location     = Path.Combine(_appSettings.TempFolder, slugItemName);

            if (CheckIfNameExist(slugItemName))
            {
                if (!force)
                {
                    return(Conflict($"name {slugItemName} exist"));
                }
                ForceCleanPublishFolderAndZip(location);
            }

            // todo: check if overlay image path: WebHtmlPublish/EmbeddedViews/default.png or something else exists

            // Creating Publish is a background task
            _bgTaskQueue.QueueBackgroundWorkItem(async token =>
            {
                var renderCopyResult = await _publishService.RenderCopy(info,
                                                                        publishProfileName, itemName, location);
                await _publishService.GenerateZip(_appSettings.TempFolder, itemName,
                                                  renderCopyResult, true);
                _webLogger.LogInformation($"[/api/publish/create] done: {itemName} {DateTime.UtcNow}");
            });

            // Get the zip  by	[HttpGet("/export/zip/{f}.zip")]
            return(Json(slugItemName));
        }