public async Task <IActionResult> CreateAmazonAccount(int id)
        {
            var actor   = ApplicationUtility.GetTokenAttribute(Request.Headers["Authorization"], "sub");
            var service = new UserRepositoryService(connString);
            var instituteAmazonAccInfo = await service.GetInstituteAmazonAccountDetail(id);

            var amazons3Service = new AmazonS3Service();
            var accname         = instituteAmazonAccInfo.UserName.ToLower();
            await amazons3Service.CreateFolder(instituteAmazonAccInfo.BucketName, accname,
                                               instituteAmazonAccInfo.AccessKey, instituteAmazonAccInfo.SecretKey);

            var amazoniamService = new AmazonIAMService();
            var iamacc           = accname + Guid.NewGuid().ToString().ToLower();
            var path             = "/" + instituteAmazonAccInfo.BucketName + "/" + instituteAmazonAccInfo.UserName.ToLower() + "/";
            var amazonaccount    = await amazoniamService.CreateIAMUser(path, iamacc);

            var model = new UserAmazonAccount()
            {
                AccessKey   = amazonaccount.AccessKey,
                Actor       = actor,
                BucketName  = instituteAmazonAccInfo.BucketName,
                BucketPath  = "/" + instituteAmazonAccInfo.UserName.ToLower(),
                IamUsername = iamacc,
                SecretKey   = amazonaccount.SecurityKey,
                UserId      = instituteAmazonAccInfo.UserId
            };
            await service.CreateUserAmazonAccount(model);

            var response = new GenericResponse <string>()
            {
                IsSuccess    = true,
                Message      = "Amazon account created successfully.",
                ResponseCode = 200,
                Result       = "Success"
            };

            return(Ok(response));
        }
Esempio n. 2
0
        private void NewFolder(FolderTreeViewModel item)
        {
            string folderName = GetInputString("New Folder", "");

            if (folderName == null)
            {
                return;
            }
            if (MessageBox.Show(Window.GetWindow(this), "Are you sure you want to create a new folder under the selected node?",
                                "Create folder?", MessageBoxButton.YesNoCancel, MessageBoxImage.Question) != MessageBoxResult.Yes)
            {
                return;
            }

            string remotePath = string.IsNullOrEmpty(item.Prefix) ? item.Prefix + folderName : item.Prefix + "/" + folderName;

            if (IsValidName(remotePath, true) == false)
            {
                return;
            }
            _amazon.CreateFolder(remotePath);
            GetBucketContents(item);
        }