Ejemplo n.º 1
0
        public static bool DeleteFromAmazonS3(string providerName, JobApplicationAttachmentType attachmentType, string itemTitle)
        {
            SiteSettingsHelper siteSettingsHelper = new SiteSettingsHelper();

            S3FilemanagerService fileManagerService = new S3FilemanagerService(_siteSettingsHelper.GetAmazonS3RegionEndpoint(), _siteSettingsHelper.GetAmazonS3AccessKeyId(), _siteSettingsHelper.GetAmazonS3SecretKey());
            var response = fileManagerService.DeleteObjectFromProvider <S3FileManagerResponse, S3FileManagerRequest>(
                new S3FileManagerRequest
            {
                FileName     = itemTitle,
                Directory    = _siteSettingsHelper.GetAmazonS3UrlName() + "/" + JobApplicationAttachmentSettings.PROFILE_RESUME_UPLOAD_LIBRARY,
                S3BucketName = _siteSettingsHelper.GetAmazonS3BucketName()
            });

            return(response != null ? response.Success : false);
        }
Ejemplo n.º 2
0
        public static Stream GetFileStreamFromAmazonS3(string srcLibName, int attachmentType, string fileTitle)
        {
            SiteSettingsHelper siteSettingsHelper = new SiteSettingsHelper();

            fileTitle = fileTitle.Split('_').First() + "_" + fileTitle;

            S3FilemanagerService fileManagerService = new S3FilemanagerService(siteSettingsHelper.GetAmazonS3RegionEndpoint(), siteSettingsHelper.GetAmazonS3AccessKeyId(), siteSettingsHelper.GetAmazonS3SecretKey());
            var response = fileManagerService.GetObjectFromProvider <S3FileManagerResponse, S3FileManagerRequest>(
                new S3FileManagerRequest
            {
                FileName     = fileTitle,
                Directory    = siteSettingsHelper.GetAmazonS3UrlName() + "/" + JobApplicationAttachmentSettings.PROFILE_RESUME_UPLOAD_LIBRARY,
                S3BucketName = siteSettingsHelper.GetAmazonS3BucketName()
            });

            return(response.FileStream);
        }
Ejemplo n.º 3
0
        public static S3FileManagerResponse UploadToAmazonS3(Guid masterDocumentId, string providerName, string libName, string fileName, Stream fileStream)
        {
            try
            {
                SiteSettingsHelper siteSettingsHelper = new SiteSettingsHelper();

                S3FilemanagerService fileManagerService = new S3FilemanagerService(_siteSettingsHelper.GetAmazonS3RegionEndpoint(), _siteSettingsHelper.GetAmazonS3AccessKeyId(), _siteSettingsHelper.GetAmazonS3SecretKey());
                var response = fileManagerService.PostObjectToProvider <S3FileManagerResponse, S3FileManagerRequest>(
                    new S3FileManagerRequest
                {
                    FileName     = masterDocumentId.ToString() + "_" + fileName,
                    Directory    = _siteSettingsHelper.GetAmazonS3UrlName() + "/" + libName,
                    FileStream   = fileStream,
                    S3BucketName = _siteSettingsHelper.GetAmazonS3BucketName(),
                    ContentType  = AmazonS3Constants.DocumentContentType
                });
                return(response);
            }
            catch (Exception)
            {
                return(null);
            }
        }