Beispiel #1
0
        public void StoreAttachmentCopy(int tenant, string user, MailAttachmentData attachment, string streamId)
        {
            try
            {
                if (attachment.streamId.Equals(streamId) && !attachment.isTemp)
                {
                    return;
                }

                string s3Key;

                var dataClient = MailDataStore.GetDataStore(tenant);

                if (attachment.needSaveToTemp || attachment.isTemp)
                {
                    s3Key = MailStoragePathCombiner.GetTempStoredFilePath(attachment);
                }
                else
                {
                    s3Key = MailStoragePathCombiner.GerStoredFilePath(attachment);
                }

                if (!dataClient.IsFile(s3Key))
                {
                    return;
                }

                attachment.fileNumber =
                    !string.IsNullOrEmpty(attachment.contentId) //Upload hack: embedded attachment have to be saved in 0 folder
                        ? 0
                        : attachment.fileNumber;

                var newS3Key = MailStoragePathCombiner.GetFileKey(user, streamId, attachment.fileNumber,
                                                                  attachment.storedName);

                var copyS3Url = dataClient.Copy(s3Key, string.Empty, newS3Key);

                attachment.storedFileUrl = MailStoragePathCombiner.GetStoredUrl(copyS3Url);

                attachment.streamId = streamId;

                attachment.tempStoredUrl = null;

                Log.DebugFormat("StoreAttachmentCopy() tenant='{0}', user_id='{1}', stream_id='{2}', new_s3_key='{3}', copy_s3_url='{4}', storedFileUrl='{5}',  filename='{6}'",
                                tenant, user, streamId, newS3Key, copyS3Url, attachment.storedFileUrl, attachment.fileName);
            }
            catch (Exception ex)
            {
                Log.ErrorFormat("CopyAttachment(). filename='{0}', ctype='{1}' Exception:\r\n{2}\r\n",
                                attachment.fileName,
                                attachment.contentType,
                                ex.ToString());

                throw;
            }
        }
        public void StoreAttachmentCopy(int id_tenant, string id_user, MailAttachment attachment, string stream_id)
        {
            try
            {
                if (attachment.streamId.Equals(stream_id))
                {
                    return;
                }

                var s3_key = MailStoragePathCombiner.GerStoredFilePath(attachment);

                var data_client = MailDataStore.GetDataStore(id_tenant);

                if (!data_client.IsFile(s3_key))
                {
                    return;
                }

                attachment.fileNumber =
                    !string.IsNullOrEmpty(attachment.contentId) //Upload hack: embedded attachment have to be saved in 0 folder
                        ? 0
                        : attachment.fileNumber;

                var new_s3_key = MailStoragePathCombiner.GetFileKey(id_user, stream_id, attachment.fileNumber,
                                                                    attachment.storedName);

                var copy_s3_url = data_client.Copy(s3_key, string.Empty, new_s3_key);

                attachment.storedFileUrl = MailStoragePathCombiner.GetStoredUrl(copy_s3_url);

                attachment.streamId = stream_id;

                _log.Debug("StoreAttachmentCopy() tenant='{0}', user_id='{1}', stream_id='{2}', new_s3_key='{3}', copy_s3_url='{4}', storedFileUrl='{5}',  filename='{6}'",
                           id_tenant, id_user, stream_id, new_s3_key, copy_s3_url, attachment.storedFileUrl, attachment.fileName);
            }
            catch (Exception ex)
            {
                _log.Error("CopyAttachment(). filename='{0}', ctype='{1}' Exception:\r\n{2}\r\n",
                           attachment.fileName,
                           attachment.contentType,
                           ex.ToString());

                throw;
            }
        }
Beispiel #3
0
        public void StoreAttachmentCopy(int id_tenant, string id_user, MailAttachment attachment, string stream_id)
        {
            try
            {
                if (!attachment.streamId.Equals(stream_id))
                {
                    var s3_key = attachment.GerStoredFilePath();

                    var data_client = GetDataStore(id_tenant);

                    if (data_client.IsFile(s3_key))
                    {
                        attachment.fileNumber =
                            !string.IsNullOrEmpty(attachment.contentId) //Upload hack: embedded attachment have to be saved in 0 folder
                                ? 0
                                : attachment.fileNumber;

                        var new_s3_key = MailStoragePathCombiner.GetFileKey(id_user, stream_id, attachment.fileNumber,
                                                                            attachment.storedName);

                        var copy_s3_url = data_client.Copy(s3_key, string.Empty, new_s3_key);

                        attachment.storedFileUrl = MailStoragePathCombiner.GetStoredUrl(copy_s3_url);

                        attachment.streamId = stream_id;
                    }
                }
            }
            catch (Exception ex)
            {
                _log.Error("CopyAttachment(). filename: {0}, ctype: {1} Exception:\r\n{2}\r\n",
                           attachment.fileName,
                           attachment.contentType,
                           ex.ToString());

                throw;
            }
        }
Beispiel #4
0
 public MailAttachGarbage(string user, int attachId, string stream, int number, string storedName)
 {
     _id   = attachId;
     _path = MailStoragePathCombiner.GetFileKey(user, stream, number, storedName);
 }
Beispiel #5
0
        // ReSharper restore InconsistentNaming

        public string GerStoredFilePath()
        {
            return(MailStoragePathCombiner.GetFileKey(user, streamId, fileNumber, storedName));
        }