public string StoreMailEml(int tenant, string user, string streamId, Message message) { // Using id_user as domain in S3 Storage - allows not to add quota to tenant. var savePath = MailStoragePathCombiner.GetEmlKey(user, streamId); var storage = MailDataStore.GetDataStore(tenant); try { using (var reader = new MemoryStream(message.OriginalData)) { var res = storage .UploadWithoutQuota(string.Empty, savePath, reader, "message/rfc822", string.Empty) .ToString(); _log.Debug("StoreMailEml() tenant='{0}', user_id='{1}', save_eml_path='{2}' Result: {3}", tenant, user, savePath, res); return(res); } } catch (Exception) { storage.Delete(string.Empty, savePath); throw; } }
public string StoreMailEml(int tenant, string user, string streamId, MimeMessage message, ILogger log) { if (message == null) { return(string.Empty); } // Using id_user as domain in S3 Storage - allows not to add quota to tenant. var savePath = MailStoragePathCombiner.GetEmlKey(user, streamId); var storage = MailDataStore.GetDataStore(tenant); try { using (var stream = new MemoryStream()) { message.WriteTo(stream); var res = storage.Save(savePath, stream, MailStoragePathCombiner.EML_FILE_NAME).ToString(); log.Debug("StoreMailEml() tenant='{0}', user_id='{1}', save_eml_path='{2}' Result: {3}", tenant, user, savePath, res); return(res); } } catch (Exception ex) { log.Error("StoreMailEml Exception: {0}", ex.ToString()); } return(string.Empty); }
public string GetMailEmlUrl(int tenant, string user, string streamId) { // Using id_user as domain in S3 Storage - allows not to add quota to tenant. var emlPath = MailStoragePathCombiner.GetEmlKey(user, streamId); var dataStore = MailDataStore.GetDataStore(tenant); try { var emlUri = dataStore.GetUri(string.Empty, emlPath); var url = MailStoragePathCombiner.GetStoredUrl(emlUri); return(url); } catch (Exception ex) { _log.Error("GetMailEmlUrl() tenant='{0}', user_id='{1}', save_eml_path='{2}' Exception: {3}", tenant, user, emlPath, ex.ToString()); } return(""); }