本文整理汇总了C#中IDataStore.UploadWithoutQuota方法的典型用法代码示例。如果您正苦于以下问题:C# IDataStore.UploadWithoutQuota方法的具体用法?C# IDataStore.UploadWithoutQuota怎么用?C# IDataStore.UploadWithoutQuota使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDataStore
的用法示例。
在下文中一共展示了IDataStore.UploadWithoutQuota方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: StoreCKeditorImageWithoutQuota
public string StoreCKeditorImageWithoutQuota(int tenant, string user, int mailboxId, string fileName, byte[] imageData, IDataStore storage)
{
try
{
if (imageData == null || imageData.Length == 0)
throw new ArgumentNullException("imageData");
var ext = string.IsNullOrEmpty(fileName) ? ".jpg" : Path.GetExtension(fileName);
if (string.IsNullOrEmpty(ext))
ext = ".jpg";
var storeName = imageData.GetMd5();
storeName = Path.ChangeExtension(storeName, ext);
var contentDisposition = ContentDispositionUtil.GetHeaderValue(storeName);
var contentType = MimeTypesHelper.GetMimeqType(ext);
var signatureImagePath = MailStoragePathCombiner.GerStoredSignatureImagePath(mailboxId, storeName);
using (var reader = new MemoryStream(imageData))
{
var uploadUrl = storage.UploadWithoutQuota(user, signatureImagePath, reader, contentType, contentDisposition);
return MailStoragePathCombiner.GetStoredUrl(uploadUrl);
}
}
catch (Exception e)
{
_log.Error("StoreCKeditorImageWithoutQuota(). filename: {0} Exception:\r\n{1}\r\n", fileName,
e.ToString());
throw;
}
}
示例2: StoreAttachmentWithoutQuota
public void StoreAttachmentWithoutQuota(int tenant, string user, MailAttachment attachment, IDataStore storage)
{
try
{
if (attachment.data == null || attachment.data.Length == 0)
return;
if (string.IsNullOrEmpty(attachment.fileName))
attachment.fileName = "attachment.ext";
var contentDisposition = MailStoragePathCombiner.PrepareAttachmentName(attachment.fileName);
var ext = Path.GetExtension(attachment.fileName);
attachment.storedName = CreateNewStreamId();
if (!string.IsNullOrEmpty(ext))
attachment.storedName = Path.ChangeExtension(attachment.storedName, ext);
attachment.fileNumber =
!string.IsNullOrEmpty(attachment.contentId) //Upload hack: embedded attachment have to be saved in 0 folder
? 0
: attachment.fileNumber;
var attachmentPath = MailStoragePathCombiner.GerStoredFilePath(attachment);
using (var reader = new MemoryStream(attachment.data))
{
var uploadUrl = storage.UploadWithoutQuota(string.Empty, attachmentPath, reader, attachment.contentType, contentDisposition);
attachment.storedFileUrl = MailStoragePathCombiner.GetStoredUrl(uploadUrl);
}
}
catch (Exception e)
{
_log.Error("StoreAttachmentWithoutQuota(). filename: {0}, ctype: {1} Exception:\r\n{2}\r\n",
attachment.fileName,
attachment.contentType,
e.ToString());
throw;
}
}