重要
サードパーティ サービスとプッシュ通知の廃止
Atlas App Services のサードパーティ サービスとプッシュ通知は非推奨となり、代わりに関数内の外部依存関係を使用する HTTP エンドポイントを作成できるようになりました。
Webhook はHTTPS endpointsに名前変更され、動作は変更されません。 既存の Webhook を移行する必要があります。
既存のサービスは、 30、2025 まで引き続き機能します。
サードパーティ サービスとプッシュ通知は非推奨になったため、App Services UI からデフォルトで削除されました。 既存のサードパーティ サービスまたはプッシュ通知を管理する必要がある場合は、次の操作を実行して構成を UI に追加できます。
左側のナビゲーションの [ App Settings Manageセクションの下にある [] をクリックします。
Temporarily Re-Enable 3rd Party Servicesの横にあるトグル スイッチを有効にし、変更を保存します。
Overview
このページのコードスニペットは、AmazonAmazon Web Services Service を通じて Simple Storage Service を使用する方法を示しています。すべてのスニペットには、スニペットで使用されるサービスアクションを許可するAmazon Web Services Service ルールの構成を持つAmazon Web Services Service インターフェースが必要です。 このコードをAtlas Function にコピーすることで、これらのスニペットを自分で実行できます。
アプリに Amazon Web Services Service インターフェースがない場合は、これらのスニペットを使用する前にAmazon Web Services Service インターフェースを作成してください。
S3 へのイメージのアップロード
この Atlas Function 643は、 putObject アクションを使用して、Base でエンコードされたイメージをAWS S にアップロードします。
exports = function(base64EncodedImage, bucket, fileName, fileType) { // Convert the base64 encoded image string to a BSON Binary object const binaryImageData = BSON.Binary.fromBase64(base64EncodedImage, 0); // Instantiate an S3 service client const s3Service = context.services.get('myS3Service').s3('us-east-1'); // Put the object to S3 return s3Service.PutObject({ 'Bucket': bucket, 'Key': fileName, 'ContentType': fileType, 'Body': binaryImageData }) .then(putObjectOutput => { console.log(putObjectOutput); // putObjectOutput: { // ETag: <string>, // The object's S3 entity tag // } return putObjectOutput }) .catch(console.error); };
関数パラメーター
Parameter | タイプ | 説明 |
---|---|---|
| string | base64 でエンコードされたイメージ。ファイル読み取り Web APIの readAsDataURL メソッドを使用して、イメージ ファイルを base に変換できます。64 |
| string | イメージを保持する S3 バケットの名前。 |
| string | ファイル拡張子を含む、イメージファイルの名前。 |
| string |
S3 からのイメージの取得
このAtlas Functionは、GetObjectアクションを使用して、Amazon Web Services S3 からオブジェクトを検索します。
exports = function(bucket, fileName) { // Instantiate an S3 service client const s3Service = context.services.get('myS3Service').s3('us-east-1'); // Get the object from S3 return s3Service.GetObject({ 'Bucket': bucket, 'Key': fileName, }) .then(getObjectOutput => { console.log(getObjectOutput); // { // ETag: <string>, // The object's S3 entity tag // Body: <binary>, // The object data // ContentType: <string>, // The object's MIME type // } const base64EncodedImage = getObjectOutput.Body return base64EncodedImage }) .catch(console.error); };
関数パラメーター
Parameter | タイプ | 説明 |
---|---|---|
| string | イメージを保持する S3 バケットの名前。 |
| string | ファイル拡張子を含む、イメージファイルの名前。 |