相关疑难解决方法(0)

GAE应用程序需要为Google云端存储创建过期的签名URL

我成功地创建了一个独立的Java应用程序,可以为Google云端存储中的资产创建过期签名URL.但是,我一直未能成功通过AppEngine确定如何为这些相同的资产创建过期签名URL.

如何创建Google云端存储资产的过期签名URL,我可以返回到客户端应用程序?

这是我的Java应用程序:

import java.io.FileInputStream;
import java.io.IOException;
import java.net.URLEncoder;
import java.security.KeyStore;
import java.security.PrivateKey;
import java.security.Signature;
import java.security.UnrecoverableKeyException;
import java.util.Calendar;

import org.apache.commons.codec.binary.Base64;

public class GCSSignedURL {

public static void main(String[] args) throws Exception {

    final String googleAccessId = "XXXXXXXXXXXX@developer.gserviceaccount.com";
    final String keyFile = "D:\\XXXXXXXXXXXXXXXXXXXXXXXXXXXXX-privatekey.p12";
    final  String keyPassword = "notasecret";
    Calendar calendar = Calendar.getInstance();
    calendar.add(Calendar.MINUTE, 30);
    String httpVerb = "GET";
    String contentMD5 = "";         
    String contentType = "";
    long expiration = calendar.getTimeInMillis();
    String canonicalizedExtensionHeaders = ""; 
    String canonicalizedResource = "/myproj/foo.txt";

    String stringToSign …
Run Code Online (Sandbox Code Playgroud)

google-app-engine google-cloud-storage

4
推荐指数
1
解决办法
2406
查看次数