Exemplo n.º 1
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;
		}
Exemplo n.º 2
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);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Sets the file associated with this attached document, and stores a copy to the document store.
        /// </summary>
        /// <returns></returns>
        public virtual void PutFile(IAttachedDocumentStore documentStore, string localFilePath)
        {
            const string pathDelimiter = "/";

            var builder = new StringBuilder();

            builder.Append(_creationTime.Year.ToString());
            builder.Append(pathDelimiter);
            builder.Append(_creationTime.Month.ToString());
            builder.Append(pathDelimiter);
            builder.Append(_creationTime.Day.ToString());
            builder.Append(pathDelimiter);

            // important that we always generate a new GUID here, because multiple AttachedDocument objects
            // are allowed to refer to the same remote resource - therefore we must treat the remote resource
            // as immutable
            builder.AppendFormat("{0}.{1}", Guid.NewGuid().ToString("D"), _fileExtension);

            _contentUrl = builder.ToString();
            documentStore.PutDocument(_contentUrl, localFilePath);
        }
Exemplo n.º 4
0
		/// <summary>
		/// Sets the file associated with this attached document, and stores a copy to the document store.
		/// </summary>
		/// <returns></returns> 
		public virtual void PutFile(IAttachedDocumentStore documentStore, string localFilePath)
		{
			const string pathDelimiter = "/";

			var builder = new StringBuilder();
			builder.Append(_creationTime.Year.ToString());
			builder.Append(pathDelimiter);
			builder.Append(_creationTime.Month.ToString());
			builder.Append(pathDelimiter);
			builder.Append(_creationTime.Day.ToString());
			builder.Append(pathDelimiter);

			// important that we always generate a new GUID here, because multiple AttachedDocument objects
			// are allowed to refer to the same remote resource - therefore we must treat the remote resource
			// as immutable
			builder.AppendFormat("{0}.{1}", Guid.NewGuid().ToString("D"), _fileExtension);

			_contentUrl = builder.ToString();
			documentStore.PutDocument(_contentUrl, localFilePath);
		}
Exemplo n.º 5
0
		/// <summary>
		/// Gets the file associated with this attached document, from the document store.
		/// </summary>
		/// <returns></returns>
		public virtual string GetFile(IAttachedDocumentStore documentStore)
		{
			return documentStore.GetDocument(_contentUrl);
		}
Exemplo n.º 6
0
 /// <summary>
 /// Gets the file associated with this attached document, from the document store.
 /// </summary>
 /// <returns></returns>
 public virtual string GetFile(IAttachedDocumentStore documentStore)
 {
     return(documentStore.GetDocument(_contentUrl));
 }