Ejemplo n.º 1
0
        private string GetAbsoluteFileUrl(Core.File file)
        {
            if (file == null)
            {
                return(string.Empty);
            }

            string path = file.Path;

            if (string.IsNullOrEmpty(path))
            {
                return(string.Empty);
            }

            string virtualPath = "/Content";

            if (!path.StartsWith("/"))
            {
                virtualPath += "/";
            }

            virtualPath += path;

            string authority      = this.Request.RequestUri.GetLeftPart(UriPartial.Authority);
            string iisVirtualPath = VirtualPathUtility.ToAbsolute("~");
            string result         = authority + iisVirtualPath + virtualPath;

            return(result);
        }
        public Core.File SaveFile(Core.File file, Stream fileStream)
        {
            if (fileStream == null)
            {
                throw new ArgumentNullException("fileStream");
            }
            ICloudFileSystemEntry entry = null;

            if (file.ID != null)
            {
                entry = SharpBoxProviderInfo.Storage.GetFile(MakePath(file.ID), null);
            }
            else if (file.FolderID != null)
            {
                var folder = GetFolderById(file.FolderID);

                file.Title = GetAvailableTitle(file.Title, folder, IsExist);

                entry = SharpBoxProviderInfo.Storage.CreateFile(folder, file.Title);
            }
            if (entry != null)
            {
                entry.GetDataTransferAccessor().Transfer(fileStream, nTransferDirection.nUpload);
                return(ToFile(entry));
            }
            return(null);
        }
        public Stream GetFileStream(Core.File file, long offset)
        {
            //NOTE: id here is not converted!
            var fileToDownload = GetFileById(file.ID);

            //Check length of the file
            if (fileToDownload == null)
            {
                throw new ArgumentNullException("file", Web.Files.Resources.FilesCommonResource.ErrorMassage_FileNotFound);
            }

            //if (fileToDownload.Length > SetupInfo.AvailableFileSize)
            //{
            //    throw FileSizeComment.FileSizeException;
            //}

            var fileStream = fileToDownload.GetDataTransferAccessor().GetDownloadStream();

            if (fileStream.CanSeek)
            {
                file.ContentLength = fileStream.Length; // hack for google drive
            }
            if (offset > 0)
            {
                fileStream.Seek(offset, SeekOrigin.Begin);
            }

            return(fileStream);
        }
Ejemplo n.º 4
0
        public void ArtifactCopyShouldRenameFile()
        {
            var destinationArtifact = new Core.File(_destination);

            _copyEngine.To(destinationArtifact);
            _fileSystemWrapper.AssertWasCalled(x => x.Copy(_source, _destination));
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Adds the file resource.
 /// </summary>
 /// <param name="context">The context.</param>
 /// <param name="resource">The resource.</param>
 /// <returns>The added <see cref="Core.File"/> type.</returns>
 private static Core.File AddFileResource(ZentityContext context, ScholarlyWork resource)
 {
     Core.File mediaResource = new Core.File();
     context.AddToResources(mediaResource);
     context.SaveChanges();
     resource.Files.Add(mediaResource);
     return(mediaResource);
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Updates the Resource.File of the specified resource.
        /// </summary>
        /// <param name="collectionName">The type of the resource.</param>
        /// <param name="memberResourceId">The resource whose File needs to be updated.</param>
        /// <param name="mimeType">The MIME type of media.</param>
        /// <param name="media">The new File contents.</param>
        /// <returns>A SyndicationItem that describes the updated resource.</returns>
        /// <exception cref="ArgumentNullException">Throws exception if collectionName is null/empty
        /// or media is null.</exception>
        /// <exception cref="ArgumentException">Throws exception if requested memberResourceId is not a unique identifier.</exception>
        SyndicationItem IAtomPubStoreWriter.UpdateMedia(string collectionName, string memberResourceId, string mimeType, byte[] media)
        {
            if (string.IsNullOrEmpty(collectionName))
            {
                throw new ArgumentNullException("collectionName");
            }

            if (null == media)
            {
                throw new ArgumentNullException("media");
            }

            if (string.IsNullOrEmpty(memberResourceId))
            {
                throw new ArgumentNullException("memberResourceId");
            }

            if (!AtomPubHelper.IsValidGuid(memberResourceId))
            {
                throw new ArgumentException(Resources.ATOMPUB_INVALID_RESOURCE_ID, "memberResourceId");
            }

            using (ZentityContext context = CoreHelper.CreateZentityContext())
            {
                Type collectionType = CoreHelper.GetSystemResourceType(collectionName);
                // Prepare a query to get a resource with specified Id and specified type.
                string commandText = string.Format(CultureInfo.InvariantCulture, AtomPubConstants.EsqlToGetFileContents,
                                                   collectionType.FullName);

                ObjectQuery <Core.File> query = new ObjectQuery <Core.File>(commandText, context);
                query.Parameters.Add(new ObjectParameter("Id", new Guid(memberResourceId)));
                Core.File mediaResource = query.FirstOrDefault();

                if (null == mediaResource)
                {
                    throw new ResourceNotFoundException(Resources.ATOMPUB_RESOURCE_NOT_FOUND);
                }

                if (!mediaResource.Authorize("Update", context, CoreHelper.GetAuthenticationToken()))
                {
                    throw new UnauthorizedException(Resources.ATOMPUB_UNAUTHORIZED);
                }

                mediaResource.Resources.Load();
                ScholarlyWork resource = (ScholarlyWork)mediaResource.Resources.First();
                resource.DateModified       = DateTime.Now;
                mediaResource.MimeType      = mimeType;
                mediaResource.FileExtension = AtomPubHelper.GetFileExtension(mimeType);

                MemoryStream mediaStream = ZentityAtomPubStoreWriter.GetMediaStream(media);
                context.UploadFileContent(mediaResource, mediaStream);

                // Bug Fix : 180811 - Save Changes once mime type and contents are set.
                context.SaveChanges();

                return(ZentityAtomPubStoreReader.GenerateSyndicationItem(this.BaseUri, resource));
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Adds the child resources.
        /// </summary>
        /// <param name="extractionPath">The extraction path.</param>
        /// <param name="document">The document.</param>
        /// <param name="resource">The resource.</param>
        /// <param name="zentityContext">The zentity context.</param>
        private static void AddChildResources(
            string extractionPath,
            MetsDocument document,
            ScholarlyWork resource,
            ZentityContext zentityContext)
        {
            resource.Container = new ScholarlyWorkContainer();
            ScholarlyWorkContainer childContainer = null;

            string[] fileNames = Directory.GetFiles(extractionPath)
                                 .Select(path => GetFileName(path))
                                 .Where(name => SwordConstants.MetsDocumentName != name)
                                 .ToArray();

            if (0 < fileNames.Length)
            {
                childContainer = new ScholarlyWorkContainer();
                resource.Container.ContainedWorks.Add(childContainer);
            }

            // Loop though all files which are extracted.
            foreach (string fileName in fileNames)
            {
                // Get the extension
                int    dotIndex      = fileName.LastIndexOf('.');
                string fileExtension = (0 < dotIndex) ? fileName.Substring(dotIndex + 1) : string.Empty;

                #region Upload Zip File Contents

                // Get Metadata for the specified fileName
                MetadataSection dataSection = document.Files[fileName];

                // Create resource against each type as specified in the METS document.
                ScholarlyWork individualResource = CreateResouceUsingMetsMetadata(dataSection);

                UpdateResourceProeprties(zentityContext, individualResource, dataSection);

                // Create Media and Upload file contents.
                Core.File individualMediaResource = AddFileResource(zentityContext,
                                                                    individualResource,
                                                                    extractionPath + "\\" + fileName);
                individualMediaResource.MimeType      = AtomPubHelper.GetMimeTypeFromFileExtension(fileExtension);
                individualMediaResource.FileExtension = fileExtension;

                // Save file name in notes for future references.
                individualMediaResource.Description = fileName;

                // Associate with the main resource.
                childContainer.ContainedWorks.Add(individualResource);

                #endregion

                AuthenticatedToken authenticatedToken = CoreHelper.GetAuthenticationToken();

                individualResource.GrantDefaultPermissions(zentityContext, authenticatedToken);
                individualMediaResource.GrantDefaultPermissions(zentityContext, authenticatedToken);
            }
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Adds the file resource.
 /// </summary>
 /// <param name="context">The context.</param>
 /// <param name="resource">The resource.</param>
 /// <param name="mediaFilePath">The media file path.</param>
 /// <returns>The added <see cref="Core.File"/> type.</returns>
 private static Core.File AddFileResource(
     ZentityContext context,
     ScholarlyWork resource,
     string mediaFilePath)
 {
     Core.File mediaResource = AddFileResource(context, resource);
     context.UploadFileContent(mediaResource, mediaFilePath);
     return(mediaResource);
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Adds the file resource.
 /// </summary>
 /// <param name="context">The context.</param>
 /// <param name="resource">The resource.</param>
 /// <param name="mediaStream">The media stream.</param>
 /// <returns>The added <see cref="Core.File"/> type.</returns>
 private static Core.File AddFileResource(
     ZentityContext context,
     ScholarlyWork resource,
     Stream mediaStream)
 {
     Core.File mediaResource = AddFileResource(context, resource);
     mediaStream.Position = 0;
     context.UploadFileContent(mediaResource, mediaStream);
     return(mediaResource);
 }
Ejemplo n.º 10
0
        public bool IsExistOnStorage(Core.File file)
        {
            var fileId   = file.ID;
            var selector = GetSelector(fileId);

            file.ID = selector.ConvertId(fileId);
            var exist = selector.GetFileDao(fileId).IsExistOnStorage(file);

            file.ID = fileId; //Restore
            return(exist);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Gets a media contents of a member resource.
        /// </summary>
        /// <param name="collectionName">Name of the target collection.</param>
        /// <param name="memberResourceId">The Id of the member resource.</param>
        /// <param name="outputStream">A stream containing the media corresponding to the specified resource. If no matching media is found, null is returned.</param>
        /// <exception cref="ArgumentNullException">Throws exception if memberResourceId is null/empty
        /// or outputStream is null.</exception>
        /// <exception cref="ArgumentException">Throws exception if outputStream stream is not readable.</exception>
        void IAtomPubStoreReader.GetMedia(string collectionName, string memberResourceId, Stream outputStream)
        {
            if (string.IsNullOrEmpty(collectionName))
            {
                throw new ArgumentNullException("collectionName");
            }

            if (string.IsNullOrEmpty(memberResourceId))
            {
                throw new ArgumentNullException("memberResourceId");
            }

            if (null == outputStream)
            {
                throw new ArgumentNullException("outputStream");
            }

            if (!AtomPubHelper.IsValidGuid(memberResourceId))
            {
                throw new ArgumentException(Resources.ATOMPUB_INVALID_RESOURCE_ID);
            }

            if (!outputStream.CanWrite)
            {
                throw new ArgumentException(Properties.Resources.ATOMPUB_CANNOT_WRITE_ON_STREAM, "outputStream");
            }

            using (ZentityContext context = CoreHelper.CreateZentityContext())
            {
                ResourceType collectionType = coreHelper.GetResourceType(collectionName);

                // Prepare a query to get a resource with specified Id and specified type.
                string commandText = string.Format(CultureInfo.InvariantCulture, AtomPubConstants.EsqlToGetFileContents,
                                                   collectionType.FullName);

                ObjectQuery <Core.File> query = new ObjectQuery <Core.File>(commandText, context);
                query.Parameters.Add(new ObjectParameter("Id", new Guid(memberResourceId)));
                Core.File mediaFile = query.FirstOrDefault();

                if (null == mediaFile)
                {
                    throw new ResourceNotFoundException(Resources.ATOMPUB_RESOURCE_NOT_FOUND);
                }

                if (!mediaFile.Authorize("Read", context, CoreHelper.GetAuthenticationToken()))
                {
                    throw new UnauthorizedException(Resources.ATOMPUB_UNAUTHORIZED);
                }

                context.DownloadFileContent(mediaFile, outputStream);
            }
        }
Ejemplo n.º 12
0
        private IFileDao GetFileDao(Core.File file)
        {
            if (file.ID != null)
            {
                return(GetSelector(file.ID).GetFileDao(file.ID));
            }

            if (file.FolderID != null)
            {
                return(GetSelector(file.FolderID).GetFileDao(file.FolderID));
            }

            throw new ArgumentException("Can't create instance of dao for given file.", "file");
        }
Ejemplo n.º 13
0
        private Core.File MakeId(Core.File file)
        {
            if (file.ID != null)
            {
                file.ID = PathPrefix + "-" + file.ID;
            }

            if (file.FolderID != null)
            {
                file.FolderID = PathPrefix + "-" + file.FolderID;
            }

            return(file);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Creates a new Resource.File for a specified resource of type collectionName in the repository.
        /// </summary>
        /// <param name="collectionName">The resource type.</param>
        /// <param name="mimeType">The MIME type of media.</param>
        /// <param name="media">The new File contents.</param>
        /// <param name="fileExtension">The media file extension.</param>
        /// <returns>A SyndicationItem that describes the newly created resource.</returns>
        /// <exception cref="ArgumentNullException">Throws exception if collectionName is null/empty
        /// or mimeType is null/empty or media is null.</exception>
        protected SyndicationItem CreateMedia(string collectionName, string mimeType, byte[] media,
                                              string fileExtension)
        {
            if (string.IsNullOrEmpty(collectionName))
            {
                throw new ArgumentNullException("collectionName");
            }

            if (string.IsNullOrEmpty(mimeType))
            {
                throw new ArgumentNullException("mimeType");
            }

            if (null == media)
            {
                throw new ArgumentNullException("media");
            }

            AuthenticatedToken authenticatedToken = CoreHelper.GetAuthenticationToken();

            using (ZentityContext context = CoreHelper.CreateZentityContext())
            {
                if (!authenticatedToken.HasCreatePermission(context))
                {
                    throw new UnauthorizedException(Resources.ATOMPUB_UNAUTHORIZED);
                }

                ScholarlyWork resource = CreateScholarlyWork(collectionName);
                resource.DateModified = DateTime.Now;

                Core.File mediaResource = new Core.File();
                mediaResource.MimeType      = mimeType;
                mediaResource.FileExtension = string.IsNullOrEmpty(fileExtension) ?
                                              AtomPubHelper.GetFileExtension(mimeType) : fileExtension;
                context.AddToResources(mediaResource);
                context.SaveChanges();
                resource.Files.Add(mediaResource);

                MemoryStream mediaStream = ZentityAtomPubStoreWriter.GetMediaStream(media);
                context.UploadFileContent(mediaResource, mediaStream);
                mediaStream.Close();

                resource.GrantDefaultPermissions(context, authenticatedToken);
                mediaResource.GrantDefaultPermissions(context, authenticatedToken);

                context.SaveChanges();

                return(ZentityAtomPubStoreReader.GenerateSyndicationItem(this.BaseUri, resource));
            }
        }
Ejemplo n.º 15
0
        public Uri GetPreSignedUri(Core.File file, TimeSpan expires)
        {
            if (file == null)
            {
                throw new ArgumentNullException("file");
            }
            var fileId   = file.ID;
            var selector = GetSelector(fileId);

            file.ID = selector.ConvertId(fileId);
            var streamUri = selector.GetFileDao(fileId).GetPreSignedUri(file, expires);

            file.ID = fileId; //Restore id

            return(streamUri);
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Get stream of file
        /// </summary>
        /// <param name="file"></param>
        /// <param name="offset"></param>
        /// <returns>Stream</returns>
        public Stream GetFileStream(Core.File file, long offset)
        {
            if (file == null)
            {
                throw new ArgumentNullException("file");
            }
            var fileId   = file.ID;
            var selector = GetSelector(fileId);

            file.ID = selector.ConvertId(fileId);
            var stream = selector.GetFileDao(fileId).GetFileStream(file, offset);

            file.ID = fileId; //Restore id

            return(stream);
        }
Ejemplo n.º 17
0
        public bool IsSupportedPreSignedUri(Core.File file)
        {
            if (file == null)
            {
                throw new ArgumentNullException("file");
            }
            var fileId   = file.ID;
            var selector = GetSelector(fileId);

            file.ID = selector.ConvertId(fileId);
            var isSupported = selector.GetFileDao(fileId).IsSupportedPreSignedUri(file);

            file.ID = fileId; //Restore id

            return(isSupported);
        }
        public HttpResponseMessage CreateFile(Guid userId, Guid directoryId, Core.File fileData)
        {
            if (fileData.DirectoryId == Guid.Empty)
            {
                fileData.DirectoryId = directoryId;
            }

            CheckPermissionResponse permissionResponse = _router.Query <CheckPermissionRequest, CheckPermissionResponse>(new CheckPermissionRequest()
            {
                IdentityId = Context.Identity.Id,
                OwnerId    = userId,
                FileId     = directoryId
            });

            bool canWrite = false;

            if (!permissionResponse.EffectivePermissions.TryGetValue(FilePermissionAction.Write, out canWrite) || !canWrite)
            {
                return(Request.CreateResponse(HttpStatusCode.Forbidden));
            }

            fileData.Id = Guid.NewGuid();

            ValidateResponse validateResp = _router.Query <ValidateRequest <Core.File>, ValidateResponse>(new ValidateRequest <Core.File>()
            {
                ObjectId = fileData.Id,
                Object   = fileData
            });

            if (validateResp.Results.Any(x => x.Level > Level.Information))
            {
                return(Request.CreateResponse((HttpStatusCode)422, new { Validation = new { Errors = validateResp.Results } }));
            }

            _router.Command(new CreateCommand <Core.File>()
            {
                Object = fileData
            });

            return(Request.CreateResponse(HttpStatusCode.OK, new { FileId = fileData.Id }));
        }
Ejemplo n.º 19
0
        public static async Task <Core.Mission> GetOrCreateMission(IMissionEngine missionEngine, string missionName, string missionImage, string seriesId)
        {
            var mission = await missionEngine.GetMissionByName(missionName);

            if (mission == null)
            {
                Core.File file = null;
                if (!string.IsNullOrWhiteSpace(missionImage))
                {
                    file = await FileLoader.GetLocalFile(missionImage);
                }
                mission = await missionEngine.Create(missionName, seriesId, file);

                Console.WriteLine($"Mission Created: {mission.MissionName}-{mission.Id}");
            }
            else
            {
                Console.WriteLine($"Mission Found: {mission.MissionName}-{mission.Id}");
            }
            return(mission);
        }
Ejemplo n.º 20
0
        public static async Task <Core.File> GetLocalFile(string path)
        {
            var fi = new FileInfo(path);
            var contentTypeProvider = new FileExtensionContentTypeProvider();

            Core.File file = null;
            if (fi != null)
            {
                using var stream = new MemoryStream();
                await fi.OpenRead().CopyToAsync(stream);

                contentTypeProvider.TryGetContentType($"{fi.Name}{fi.Extension}", out var contentType);
                file = new Core.File
                {
                    FileName    = fi.Name,
                    ContentType = contentType,
                    FileContent = stream.ToArray(),
                };
            }
            return(file);
        }
Ejemplo n.º 21
0
        public static async Task <Core.Series> GetOrCreateSeries(ISeriesEngine _seriesEngine, string seriesName, string seriesImage)
        {
            var series = await _seriesEngine.GetSeriesByName(seriesName);

            if (series == null)
            {
                Core.File file = null;
                if (!string.IsNullOrWhiteSpace(seriesImage))
                {
                    file = await FileLoader.GetLocalFile(seriesImage);
                }
                series = await _seriesEngine.CreateSeries(seriesName, file);

                Console.WriteLine($"Series Created: {series.SeriesName}-{series.Id}");
            }
            else
            {
                Console.WriteLine($"Series Found: {series.SeriesName}-{series.Id}");
            }
            return(series);
        }
Ejemplo n.º 22
0
        public ChunkedUploadSession CreateUploadSession(Core.File file, long contentLength)
        {
            if (SetupInfo.ChunkUploadSize > contentLength)
            {
                return new ChunkedUploadSession(MakeId(file), contentLength)
                       {
                           UseChunks = false
                       }
            }
            ;

            var uploadSession = new ChunkedUploadSession(file, contentLength);

            ICloudFileSystemEntry sharpboxFile;

            if (file.ID != null)
            {
                sharpboxFile = GetFileById(file.ID);
            }
            else
            {
                var folder = GetFolderById(file.FolderID);
                sharpboxFile = SharpBoxProviderInfo.Storage.CreateFile(folder, GetAvailableTitle(file.Title, folder, IsExist));
            }

            var sharpboxSession = sharpboxFile.GetDataTransferAccessor().CreateResumableSession(contentLength);

            if (sharpboxSession != null)
            {
                uploadSession.Items["SharpboxSession"] = sharpboxSession;
            }
            else
            {
                uploadSession.Items["TempPath"] = Path.GetTempFileName();
            }

            uploadSession.File = MakeId(uploadSession.File);
            return(uploadSession);
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Deletes the Resource.File for the specified resource.
        /// </summary>
        /// <param name="collectionName">The type of the resource.</param>
        /// <param name="memberResourceId">The Guid of the resource.</param>
        /// <returns>True if the operation succeeds, False otherwise.</returns>
        /// <exception cref="ArgumentNullException">Throws exception if collectionName is null/empty.</exception>
        /// <exception cref="ArgumentException">Throws exception if requested memberResourceId is not a unique identifier.</exception>
        bool IAtomPubStoreWriter.DeleteMedia(string collectionName, string memberResourceId)
        {
            if (string.IsNullOrEmpty(collectionName))
            {
                throw new ArgumentNullException("collectionName");
            }

            if (!AtomPubHelper.IsValidGuid(memberResourceId))
            {
                throw new ArgumentException(Resources.ATOMPUB_INVALID_RESOURCE_ID, "memberResourceId");
            }

            using (ZentityContext context = CoreHelper.CreateZentityContext())
            {
                Type   collectionType = CoreHelper.GetSystemResourceType(collectionName);
                string commandText    = string.Format(CultureInfo.InvariantCulture, AtomPubConstants.EsqlToGetFileContents,
                                                      collectionType.FullName);

                ObjectQuery <Core.File> query = new ObjectQuery <Core.File>(commandText, context);
                query.Parameters.Add(new ObjectParameter("Id", new Guid(memberResourceId)));

                Core.File mediaFile = query.FirstOrDefault();

                if (null == mediaFile)
                {
                    throw new ResourceNotFoundException(Resources.ATOMPUB_RESOURCE_NOT_FOUND);
                }

                if (!mediaFile.Authorize("Delete", context, CoreHelper.GetAuthenticationToken()))
                {
                    throw new UnauthorizedException(Resources.ATOMPUB_UNAUTHORIZED);
                }

                DeleteRelationships(context, mediaFile);
                context.DeleteObject(mediaFile);
                context.SaveChanges();
                return(true);
            }
        }
Ejemplo n.º 24
0
        public Core.File SaveFile(Core.File file, Stream fileStream)
        {
            if (file == null)
            {
                throw new ArgumentNullException("file");
            }

            var fileId   = file.ID;
            var folderId = file.FolderID;

            IDaoSelector selector;

            Core.File fileSaved = null;
            //Convert
            if (fileId != null)
            {
                selector = GetSelector(fileId);
                file.ID  = selector.ConvertId(fileId);
                if (folderId != null)
                {
                    file.FolderID = selector.ConvertId(folderId);
                }
                fileSaved = selector.GetFileDao(fileId).SaveFile(file, fileStream);
            }
            else if (folderId != null)
            {
                selector      = GetSelector(folderId);
                file.FolderID = selector.ConvertId(folderId);
                fileSaved     = selector.GetFileDao(folderId).SaveFile(file, fileStream);
            }

            if (fileSaved != null)
            {
                return(fileSaved);
            }
            throw new ArgumentException("No file id or folder id toFolderId determine provider");
        }
Ejemplo n.º 25
0
        public async Task <IActionResult> CreateMission([FromForm] CreateMissionParams missionParams)
        {
            var requestFile = missionParams.Files.FirstOrDefault();

            Core.File file = null;
            if (requestFile != null)
            {
                file = new Core.File
                {
                    ContentType = requestFile?.ContentType,
                    FileName    = requestFile?.FileName,
                };
                using (var stream = new MemoryStream())
                {
                    await requestFile.OpenReadStream().CopyToAsync(stream);

                    file.FileContent = stream.ToArray();
                }
            }

            var mission = await _missionEngine.Create(missionParams.MissionName, missionParams.SeriesId, file);

            return(Ok(mission));
        }
Ejemplo n.º 26
0
        public async Task <IActionResult> CreateSeries([FromForm] CreateSeriesParams seriesParams)
        {
            var requestFile = seriesParams.Files.FirstOrDefault();

            Core.File file = null;
            if (requestFile != null)
            {
                file = new Core.File
                {
                    ContentType = requestFile?.ContentType,
                    FileName    = requestFile?.FileName,
                };
                using (var stream = new MemoryStream())
                {
                    await requestFile.OpenReadStream().CopyToAsync(stream);

                    file.FileContent = stream.ToArray();
                }
            }

            var series = await _seriesEngine.CreateSeries(seriesParams.SeriesName, file);

            return(Ok(series));
        }
Ejemplo n.º 27
0
 public bool IsSupportedPreSignedUri(Core.File file)
 {
     return(false);
 }
Ejemplo n.º 28
0
 public bool IsExistOnStorage(Core.File file)
 {
     return(true);
 }
Ejemplo n.º 29
0
 public bool UseTrashForRemove(Core.File file)
 {
     return(false);
 }
Ejemplo n.º 30
0
 public Stream GetFileStream(Core.File file)
 {
     return(GetFileStream(file, 0));
 }
Ejemplo n.º 31
0
 public void ArtifactCopyShouldRenameFile()
 {
     var destinationArtifact = new Core.File(_destination);
     _copyEngine.To(destinationArtifact);
     _fileSystemWrapper.AssertWasCalled(x => x.Copy(_source, _destination));
 }
Ejemplo n.º 32
0
 /// <summary>
 /// 	Returns a file - an old if it is already there, or a new
 /// </summary>
 /// <param name="aName"> </param>
 /// <param name="aSize"> </param>
 /// <returns> </returns>
 public Core.File NewFile(string aName, Int64 aSize)
 {
     var tFile = File(aName, aSize);
     if (tFile == null)
     {
         tFile = new Core.File(aName, aSize);
         _files.Add(tFile);
         try
         {
             Directory.CreateDirectory(Settings.Instance.TempPath + tFile.TmpPath);
         }
         catch (Exception ex)
         {
             Log.Fatal("NewFile()", ex);
             tFile = null;
         }
     }
     return tFile;
 }
        public void StandardValidator_FormatStyle_Attributes()
        {
            Core.File file;
            Segment segment;
            SpanningCodeEnd end;
            SpanningCodeStart start;
            Unit unit;

            segment = new Segment("sx");
            segment.Source = new Source();
            unit = new Unit("ux");
            unit.Resources.Add(segment);

            file = new Core.File("fx");
            file.Containers.Add(unit);

            this.DeserializeDocument();
            this._document.Files.Add(file);

            start = new SpanningCodeStart();
            start.Id = "sc1";
            segment.Source.Text.Add(start);

            end = new SpanningCodeEnd();
            end.Isolated = false;
            end.FormatStyle = FormatStyleValue.Anchor;
            end.StartReference = start.Id;
            segment.Source.Text.Add(end);

            Console.WriteLine("Test fs with ec not isolated.");
            this.VerifyValidationException(ValidationError.FormatStyleWithSpanEndNotIsolated);
            end.Isolated = true;
            end.StartReference = null;
            start.Isolated = true;

            Console.WriteLine("Test subfs without fs.");
            end.FormatStyle = null;
            end.SubFormatStyle.Add("key", "value");
            this.VerifyValidationException(ValidationError.FormatStyleSubFormatWithoutFormat);

            Console.WriteLine("Test with valid data.");
            end.FormatStyle = FormatStyleValue.Anchor;
            StandardValidatorTests._validator.Validate(this._document);
        }