Шифрование на стороне сервера Amazon AWS в ios swift

function send() {
  setTimeout(function() {
    window.open("mailto:" + document.getElementById('email').value + "?subject=" + document.getElementById('subject').value + "&body=" + document.getElementById('message').value);
  }, 320);
}
input {
  text-align: center;
  border-top: none;
  border-right: none;
  border-left: none;
  height: 10vw;
  font-size: 2vw;
  width: 100vw;
}

textarea {
  text-align: center;
  border-top: none;
  border-right: none;
  border-left: none;
  border-radius: 5px;
  width: 100vw;
  height: 50vh;
  font-size: 2vw;
}

button {
  border: none;
  background-color: white;
  position: fixed;
  right: 5px;
  top: 5px;
  transition: transform .5s;
}

input:focus {
  outline: none;
  color: orange;
  border-radius: 3px;
}

textarea:focus {
  outline: none;
  color: orange;
  border-radius: 7px;
}

button:focus {
  outline: none;
  transform: scale(0);
  transform: rotate(360deg);
}
<!DOCTYPE html>
<html>

<head>
  <title>Send Email</title>
</head>

<body align=center>
  <input id="email" type="email" placeholder="yourfreind@something.somthing"></input><br><br>
  <input id="subject" placeholder="Subject"></input><br>
  <textarea id="message" placeholder="Message"></textarea><br>
  <button id="send" onclick="send()"><img src=https://www.dropbox.com/s/chxcszvnrdjh1zm/send.png?dl=1 width=50px height=50px></img></button>
</body>

</html>

0
задан Lukas Würzburger 13 July 2018 в 12:43
поделиться

1 ответ

Я бы рекомендовал использовать TransferUtility вместо TransferManager. TransferManager находится на пути устаревания и не имеет всех функций, которые имеет TransferUtility. Вот фрагмент кода, показывающий, как вы можете загрузить файл с помощью шифрования на стороне сервера.

 let transferUtility = AWSS3TransferUtility.default()
 let uploadExpression = AWSS3TransferUtilityUploadExpression()
 uploadExpression.setValue("AES256", forRequestHeader: "x-amz-server-side-encryption")

 uploadExpression.progressBlock = {(task, progress) in
     print("Upload progress: ", progress.fractionCompleted)
 }

 let uploadCompletionHandler = { (task: AWSS3TransferUtilityUploadTask, error: Error?) -> Void in
        if let error = error {
              //Error completing transfer. Handle Error
        }
        else {
               //Successfully uploaded.
               ......
               return nil
         }
    }

    transferUtility.uploadData(
        data,
        bucket: "bucket",
        key: "key",
        contentType: "contenttype",
        expression: uploadExpression,
        completionHandler: uploadCompletionHandler
        ).continueWith (block: { (task) -> Any? in
            if let error = task.error {
                //Error initiating transfer. Handle error
            }

            return nil
        })

}

Вот ссылка на дополнительную информацию о том, как использовать TransferUtility - https://docs.aws .amazon.com / aws-mobile / latest / developerguide / how-to-transfer-files-with-transfer-utility.html

0
ответ дан Bommas 17 August 2018 в 12:59
поделиться
  • 1
    Этот код работал, и файл был загружен в ведро S3. Но как передать SSE_CUSTOMER_KEY, как это сделано в коде Android? – Mano 16 July 2018 в 10:58
  • 2
    Вы можете установить его в uploadExpression: uploadExpression.setValue(key, forRequestHeader: "x-amz-server-side-encryption-customer-key") – Karthikeyan 17 July 2018 в 16:41
Другие вопросы по тегам:

Похожие вопросы: