/// <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; }
/// <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); }
/// <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); }
/// <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); }
/// <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)); }