2017-03-28 9 views
1

dart-lang/gcloudを使用してGoogle Cloud Storageにファイルを読み書きすると、お客様が提供する暗号化キーを提供できますか?ダーツ/ gcloudを使用したユーザー提供の暗号化キー

ダーツgcloudライブラリはdart-lang/googleapisの上に構築されていますが、それ自体はCloud Storage REST APIとのインターフェイスですが、使用するHTTPクライアントは抽象化されているため、カスタム暗号化に必要なヘッダーの設定方法は分かりません。

答えて

1

現在、カスタム暗号化キーのサポートはpackage:gcloudにありません。

Storage constructorhttp:クライアントを受け入れますが。だからあなたは、ヘッダに次の行に沿って何かを追加する独自のクライアントを提供することができます:

import 'package:http/http.dart' as http; 
import 'package:gcloud/storage.dart' as storage; 

class ClientWithKeys extends http.client { 
    final String encryptionAlgorithm; 
    final String encryptionKey; 
    final String encryptionSHA256; 

    ClientWithKeys(this.encriptionAlgorithm, 
       this.encriptionKey, 
       this.encryptionSHA256); 

    Future<StreamedResponse> send(request) { 
    request.headers['x-goog-encryption-algorithm'] = encryptionAlgorithm; 
    request.headers['x-goog-encryption-key'] = encryptionKey; 
    request.headers['x-goog-encryption-key-sha256'] = encryptionSHA256; 
    return super.send(request); 
    } 
} 

code() { 
    final client = new ClientWithKeys('<algo>', '<key>', '<sha256>'); 
    final api = new storage.Storage(client, '<project-id>'); 
    ... 
    client.close(); 
} 
関連する問題