コード例 #1
0
ファイル: DocumentsService.cs プロジェクト: nhannd/Xian
		public UploadResponse Upload(UploadRequest request)
		{
			var tempFile = Path.GetTempFileName();
			try
			{
				// write data to a temp file
				File.WriteAllBytes(tempFile, request.DataContent);

				// create the new document object, and put the remote file
				var args = new AttachedDocumentCreationArgs
				{
					MimeType = request.MimeType,
					FileExtension = request.FileExtension,
					LocalContentFilePath = tempFile
				};

				var document = AttachedDocument.Create(args, AttachmentStore.GetClient());
				PersistenceContext.Lock(document, DirtyState.New);

				PersistenceContext.SynchState();

				var assembler = new AttachedDocumentAssembler();
				return new UploadResponse(assembler.CreateAttachedDocumentSummary(document));

			}
			finally
			{
				File.Delete(tempFile);
			}
		}
コード例 #2
0
ファイル: AttachedDocument.cs プロジェクト: nhannd/Xian
		/// <summary>
		/// Creates a <see cref="AttachedDocument"/> instance, uploading the specified file to the document store.
		/// </summary>
		/// <param name="args"></param>
		/// <param name="documentStore"></param>
		/// <returns></returns>
		public static AttachedDocument Create(AttachedDocumentCreationArgs args, IAttachedDocumentStore documentStore)
		{
			// create the new document object, and put the remote file
			var document = new AttachedDocument
				{
					MimeType = args.MimeType,
					FileExtension = args.FileExtension,
				};

			document.PutFile(documentStore, args.LocalContentFilePath);
			return document;
		}
コード例 #3
0
        /// <summary>
        /// Creates a <see cref="AttachedDocument"/> instance, uploading the specified file to the document store.
        /// </summary>
        /// <param name="args"></param>
        /// <param name="documentStore"></param>
        /// <returns></returns>
        public static AttachedDocument Create(AttachedDocumentCreationArgs args, IAttachedDocumentStore documentStore)
        {
            // create the new document object, and put the remote file
            var document = new AttachedDocument
            {
                MimeType      = args.MimeType,
                FileExtension = args.FileExtension,
            };

            document.PutFile(documentStore, args.LocalContentFilePath);
            return(document);
        }