简体   繁体   English

在Google App Engine Flex上运行时,使用Java将文件从Google存储桶移动到Google云端硬盘

[英]Move file from Google Storage Bucket to Google Drive using Java while running on the Google App Engine Flex

I am running an application on the Google App Engine Flex environment. 我正在Google App Engine Flex环境上运行应用程序。 My goal is to allow file uploads from the application to a Google Drive. 我的目标是允许文件从应用程序上传到Google云端硬盘。 Since the App Engine does not have a file system (or one that I really understand), Google's documentation says to upload to a Storage Bucket: 由于App Engine没有文件系统(或我真正理解的文件系统),因此Google的文档说要上传到存储桶:

https://cloud.google.com/appengine/docs/flexible/java/using-cloud-storage https://cloud.google.com/appengine/docs/flexible/java/using-cloud-storage

I have that code working great - uploading to the Storage Bucket. 我的代码工作得很好-上传到存储桶。 The Google Drive code is also working great. Google云端硬盘代码也可以正常运行。

My question is - how do I get the Storage Bucket file up to the Google Drive? 我的问题是-如何将存储桶文件保存到Google云端硬盘?

I found a few posts, which suggest that I have to download the file from the Storage Bucket, which, from my understanding, would have to be saved to a file system and then picked up by the Google Drive code to upload to the Google Drive. 我发现了一些帖子,这表明我必须从存储桶中下载文件,据我所知,该存储桶必须保存到文件系统中,然后由Google云端硬盘代码提取才能上传到Google云端硬盘。

copy file from Google Drive to Google Cloud Storage within Google 将文件从Google云端硬盘复制到Google内的Google Cloud Storage

How to download a file from Google Cloud Storage with Java? 如何使用Java从Google Cloud Storage下载文件?

All I need to do is to set a java.io.File object from the Storage Bucket download. 我需要做的就是从“存储桶”下载中设置一个java.io.File对象。 I have the blob.getMediaLink() returned from the Google Storage code - is it possible to use that instead of downloading? 我有从Google存储区代码返回的blob.getMediaLink() -是否可以使用它代替下载?

Google Storage code: Google存储空间代码:

public static String sendFileToBucket(InputStream fileStream, String fileName) throws IOException {
    Logger.info("GoogleStorage: sendFileToBucket: Starting...");

    GoogleCredential credential = null;
    String credentialsFileName = "";
    Storage storage = null;
    Blob blob = null;
    List<Acl> acls = null;

    // credential = authorize();

    // storage = StorageOptions.getDefaultInstance().getService();

    try {
        Logger.info("GoogleStorage: sendFileToBucket: Getting credentialsFileName path...");
        credentialsFileName = Configuration.root().getString("google.storage.credentials.file");
        Logger.info("GoogleStorage: sendFileToBucket: credentialsFileName = " + credentialsFileName);

        Logger.info("GoogleStorage: sendFileToBucket: Setting InputStream...");
        InputStream in = GoogleStorage.class.getClassLoader().getResourceAsStream(credentialsFileName);
        if (in == null) {
            Logger.info("GoogleStorage: sendFileToBucket: InputStream is null");
        }
        Logger.info("GoogleStorage: sendFileToBucket: InputStream set...");

        try {
            storage = StorageOptions.newBuilder().setCredentials(ServiceAccountCredentials.fromStream(in)).build()
                    .getService();
        } catch (StorageException se) {
            System.out.println("--- START ERROR WITH SETTING STORAGE OBJECT ---");
            se.printStackTrace();
            System.out.println("--- END ERROR WITH SETTING STORAGE OBJECT ---");
        }

        // Modify access list to allow all users with link to read file
        acls = new ArrayList<>();
        acls.add(Acl.of(Acl.User.ofAllUsers(), Acl.Role.READER));

        try {
            Logger.info("GoogleStorage: sendFileToBucket: Setting Blob object...");
            blob = storage.create(BlobInfo.newBuilder(BUCKET_NAME, fileName).setAcl(acls).build(), fileStream);
            Logger.info("GoogleStorage: sendFileToBucket: Blob Object set...");
        } catch (StorageException se) {
            System.out.println("--- START ERROR WITH SETTING BLOB OBJECT ---");
            se.printStackTrace();
            System.out.println("--- END ERROR WITH SETTING BLOB OBJECT ---");
        }
    } catch (IOException ex) {
        System.out.println("--- START ERROR SENDFILETOBUCKET ---");
        ex.printStackTrace();
        System.out.println("--- END ERROR SENDFILETOBUCKET ---");
    }
    Logger.info("GoogleStorage: sendFileToBucket: blob.getMediaLink() = " + blob.getMediaLink());
    return blob.getMediaLink();
}

Google Drive code: Google云端硬盘代码:

public static String uploadFile(java.io.File file, String folderIDToFind) throws IOException {
    String fileID = "";
    String fileName = "";
    try {
        Logger.info("GoogleDrive: uploadFile: Starting File Upload...");
        // Build a new authorized API client service.
        Drive service = getDriveService();
        Logger.info("GoogleDrive: uploadFile: Completed Drive Service...");

        // Set the folder...
        String folderID = Configuration.root().getString("google.drive.folderid");
        Logger.info("GoogleDrive: uploadFile: Folder ID = " + folderID);

        String folderIDToUse = getSubfolderID(service, folderID, folderIDToFind);

        String fullFilePath = file.getAbsolutePath();
        Logger.info("GoogleDrive: uploadFile: Full File Path: " + fullFilePath);
        File fileMetadata = new File();

        // Let's see what slashes exist to get the correct file name...
        if (fullFilePath.contains("/")) {
            fileName = StringControl.rightBack(fullFilePath, "/");
        } else {
            fileName = StringControl.rightBack(fullFilePath, "\\");
        }
        String fileContentType = getContentType(fileName);
        Logger.info("GoogleDrive: uploadFile: File Content Type: " + fileContentType);
        fileMetadata.setName(fileName);
        Logger.info("GoogleDrive: uploadFile: File Name = " + fileName);

        Logger.info("GoogleDrive: uploadFile: Setting the folder...");
        fileMetadata.setParents(Collections.singletonList(folderIDToUse));
        Logger.info("GoogleDrive: uploadFile: Folder set...");

        // Team Drive settings...
        fileMetadata.set("supportsTeamDrives", true);

        FileContent mediaContent = new FileContent(fileContentType, file);

        File fileToUpload = service.files().create(fileMetadata, mediaContent).setSupportsTeamDrives(true)
                .setFields("id, parents").execute();

        fileID = fileToUpload.getId();
        Logger.info("GoogleDrive: uploadFile: File ID: " + fileID);
    } catch (Exception ex) {
        System.out.println(ex.toString());
        ex.printStackTrace();
    }
    Logger.info("GoogleDrive: uploadFile: Ending File Upload...");
    return fileID;
}

In the post above, I see how to get the Storage Bucket file - but how to do I get that over to the java.io.file object: 在上面的文章中,我看到了如何获取存储桶文件-但如何将其转移到java.io.file对象:

How to download a file from Google Cloud Storage with Java? 如何使用Java从Google Cloud Storage下载文件?

Appreciate the help. 感谢帮助。

You need to download the file to your local machine from GCS (Google Cloud Storage) and then have your Java code pick it up and send to Google Drive. 您需要从GCS(Google Cloud Storage)将文件下载到本地计算机,然后让您的Java代码将其拾取并发送到Google云端硬盘。

The second part of your code can be used. 可以使用代码的第二部分。 But your first part is actually uploading a file to GCS and then obtaining a serving URL. 但是您的第一部分实际上是将文件上传到GCS,然后获取服务网址。 I don't think you want that. 我不想要你

Instead look into downloading from GCS , and then ran the second part of your code and upload that file to Google Drive. 而是考虑从GCS下载 ,然后运行代码的第二部分并将该文件上传到Google云端硬盘。

=== ===

If you are using App Engine and doesn't want to use a local machine to perform the uploading, you can try the following: 如果您使用的是App Engine,并且不想使用本地计算机执行上传,则可以尝试以下操作:

Read from GCS and get the file to outputStream in the HTTP response . 从GCS读取并在HTTP响应中将文件获取到outputStream You can then upload the file to Google Drive . 然后,您可以将文件上传到Google云端硬盘 There's a bit of code to add, you need to make sure the byte stream you get is converted to a java.io.File. 需要添加一些代码,您需要确保将获取的字节流转换为java.io.File。

With many thanks to @Ying Li, I finally have a solution. 非常感谢@Ying Li,我终于有了解决方案。 I ended up creating a temp java.io.File using the blob.getMediaLink() URL that is returned once you upload to a Storage bucket. 我最终使用blob.getMediaLink() URL创建了一个临时java.io.File ,一旦您将其上传到存储桶,该URL就会返回。 Here is the method I created: 这是我创建的方法:

public static java.io.File createFileFromURL(String fileURL, String fileName) throws IOException {

    java.io.File tempFile = null;

    try {
        URL url = new URL(fileURL);
        Logger.info("GoogleControl: createFileFromURL: url = " + url);
        Logger.info("GoogleControl: createFileFromURL: fileName = " + fileName);
        String filePrefix = StringControl.left(fileName, ".") + "_";
        String fileExt = "." + StringControl.rightBack(fileName, ".");
        Logger.info("GoogleControl: createFileFromURL: filePrefix = " + filePrefix);
        Logger.info("GoogleControl: createFileFromURL: fileExt = " + fileExt);

        tempFile = java.io.File.createTempFile(filePrefix, fileExt);

        tempFile.deleteOnExit();
        FileUtils.copyURLToFile(url, tempFile);
        Logger.info("GoogleControl: createFileFromURL: tempFile name = " + tempFile.getName());
    } catch (Exception ex) {
        System.out.println(ex.toString());
        ex.printStackTrace();
    }

    return tempFile;
}

So, the full class looks like this: 因此,完整的类如下所示:

package google;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

import org.apache.commons.io.FileUtils;

import com.google.api.client.googleapis.auth.oauth2.GoogleCredential;
import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport;
import com.google.api.client.http.FileContent;
import com.google.api.client.http.HttpTransport;
import com.google.api.client.json.JsonFactory;
import com.google.api.client.json.jackson2.JacksonFactory;
import com.google.api.client.util.store.FileDataStoreFactory;
import com.google.api.services.drive.Drive;
import com.google.api.services.drive.DriveScopes;
import com.google.api.services.drive.model.File;
import com.google.api.services.drive.model.FileList;
import com.google.auth.oauth2.*;
import com.google.cloud.storage.*;

import controllers.GlobalUtilities.StringControl;
import play.Configuration;
import play.Logger;

/**
 * @author Dan Zeller
 *
 */

public class GoogleControl {

    private static final String APPLICATION_NAME = "PTP";
    private static final JsonFactory JSON_FACTORY = JacksonFactory.getDefaultInstance();
    private static HttpTransport HTTP_TRANSPORT;
    private static final String BUCKET_NAME = Configuration.root().getString("google.storage.bucket.name");
    public static final String FILE_PREFIX = "stream2file";
    public static final String FILE_SUFFIX = ".tmp";

    static {
        try {
            HTTP_TRANSPORT = GoogleNetHttpTransport.newTrustedTransport();
        } catch (Throwable t) {
            t.printStackTrace();
            System.exit(1);
        }
    }

    @SuppressWarnings("deprecation")
    public static GoogleCredential authorize() throws IOException {
        GoogleCredential credential = null;
        String credentialsFileName = "";
        try {
            Logger.info("GoogleControl: authorize: Starting...");

            Logger.info("GoogleControl: authorize: Getting credentialsFileName path...");
            credentialsFileName = Configuration.root().getString("google.drive.credentials.file");
            Logger.info("GoogleControl: authorize: credentialsFileName = " + credentialsFileName);

            Logger.info("GoogleControl: authorize: Setting InputStream...");
            InputStream in = GoogleControl.class.getClassLoader().getResourceAsStream(credentialsFileName);
            if (in == null) {
                Logger.info("GoogleControl: authorize: InputStream is null");
            }
            Logger.info("GoogleControl: authorize: InputStream set...");

            Logger.info("GoogleControl: authorize: Setting credential...");
            credential = GoogleCredential.fromStream(in, HTTP_TRANSPORT, JSON_FACTORY)
                    .createScoped(Collections.singleton(DriveScopes.DRIVE));
        } catch (IOException ex) {
            System.out.println(ex.toString());
            System.out.println("Could not find file " + credentialsFileName);
            ex.printStackTrace();
        }
        Logger.info("GoogleControl: authorize: Ending...");
        return credential;
    }

    public static java.io.File createFileFromURL(String fileURL, String fileName) throws IOException {

        java.io.File tempFile = null;

        try {
            URL url = new URL(fileURL);
            Logger.info("GoogleControl: createFileFromURL: url = " + url);
            Logger.info("GoogleControl: createFileFromURL: fileName = " + fileName);
            String filePrefix = StringControl.left(fileName, ".") + "_";
            String fileExt = "." + StringControl.rightBack(fileName, ".");
            Logger.info("GoogleControl: createFileFromURL: filePrefix = " + filePrefix);
            Logger.info("GoogleControl: createFileFromURL: fileExt = " + fileExt);

            tempFile = java.io.File.createTempFile(filePrefix, fileExt);

            tempFile.deleteOnExit();
            FileUtils.copyURLToFile(url, tempFile);
            Logger.info("GoogleControl: createFileFromURL: tempFile name = " + tempFile.getName());
        } catch (Exception ex) {
            System.out.println(ex.toString());
            ex.printStackTrace();
        }

        return tempFile;
    }

    public static void downloadFile(String fileID) {
        // Set the drive service...
        Drive service = null;
        try {
            service = getDriveService();
        } catch (IOException e) {
            e.printStackTrace();
        }
        OutputStream outputStream = new ByteArrayOutputStream();
        try {
            service.files().get(fileID).executeMediaAndDownloadTo(outputStream);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static String getContentType(String filePath) throws Exception {
        String type = "";
        try {
            Path path = Paths.get(filePath);
            type = Files.probeContentType(path);
            System.out.println(type);
        } catch (Exception ex) {
            System.out.println(ex.toString());
            ex.printStackTrace();
        }
        return type;
    }

    public static Drive getDriveService() throws IOException {
        Logger.info("GoogleControl: getDriveService: Starting...");
        GoogleCredential credential = null;
        Drive GoogleControl = null;
        try {
            credential = authorize();
            Logger.info("GoogleControl: getDriveService: Credentials set...");
            try {
                GoogleControl = new Drive.Builder(HTTP_TRANSPORT, JSON_FACTORY, credential)
                        .setApplicationName(APPLICATION_NAME).build();
            } catch (Exception ex) {
                System.out.println(ex.toString());
                ex.printStackTrace();
            }

        } catch (IOException ex) {
            System.out.println(ex.toString());
            ex.printStackTrace();
        }
        return GoogleControl;
    }

    public static String getPath() {
        String s = GoogleControl.class.getName();
        int i = s.lastIndexOf(".");
        if (i > -1)
            s = s.substring(i + 1);
        s = s + ".class";
        System.out.println("Class Name: " + s);
        Object testPath = GoogleControl.class.getResource(s);
        System.out.println("Current Path: " + testPath);
        return "";
    }

    public static String getSubfolderID(Drive service, String parentFolderID, String folderKeyToGet) {
        // We need to see if the folder exists based on the ID...
        String folderID = "";
        Boolean foundFolder = false;
        FileList result = null;
        File newFolder = null;

        // Set the drive query...
        String driveQuery = "mimeType='application/vnd.google-apps.folder' and '" + parentFolderID
                + "' in parents and name='" + folderKeyToGet + "' and trashed=false";

        try {
            result = service.files().list().setQ(driveQuery).setIncludeTeamDriveItems(true).setSupportsTeamDrives(true)
                    .execute();
        } catch (IOException e) {
            e.printStackTrace();
        }
        for (File folder : result.getFiles()) {
            System.out.printf("Found folder: %s (%s)\n", folder.getName(), folder.getId());
            foundFolder = true;
            folderID = folder.getId();
        }
        if (foundFolder != true) {
            // Need to create the folder...
            File fileMetadata = new File();
            fileMetadata.setName(folderKeyToGet);
            fileMetadata.setTeamDriveId(parentFolderID);
            fileMetadata.set("supportsTeamDrives", true);
            fileMetadata.setMimeType("application/vnd.google-apps.folder");
            fileMetadata.setParents(Collections.singletonList(parentFolderID));

            try {
                newFolder = service.files().create(fileMetadata).setSupportsTeamDrives(true).setFields("id, parents")
                        .execute();
            } catch (IOException e) {
                e.printStackTrace();
            }
            // Send back the folder ID...
            folderID = newFolder.getId();
            System.out.println("Folder ID: " + newFolder.getId());
        }

        return folderID;
    }

    @SuppressWarnings("deprecation")
    public static java.io.File sendFileToBucket(InputStream fileStream, String fileName) throws Exception {
        Logger.info("GoogleControl: sendFileToBucket: Starting...");

        GoogleCredential credential = null;
        String credentialsFileName = "";
        String outputFileName = "";
        Storage storage = null;
        Blob blob = null;
        List<Acl> acls = null;
        java.io.File returnFile = null;

        try {
            Logger.info("GoogleControl: sendFileToBucket: Getting credentialsFileName path...");
            credentialsFileName = Configuration.root().getString("google.storage.credentials.file");
            Logger.info("GoogleControl: sendFileToBucket: credentialsFileName = " + credentialsFileName);

            Logger.info("GoogleControl: sendFileToBucket: Setting InputStream...");
            InputStream in = GoogleControl.class.getClassLoader().getResourceAsStream(credentialsFileName);
            if (in == null) {
                Logger.info("GoogleControl: sendFileToBucket: InputStream is null");
            }
            Logger.info("GoogleControl: sendFileToBucket: InputStream set...");

            try {
                storage = StorageOptions.newBuilder().setCredentials(ServiceAccountCredentials.fromStream(in)).build()
                        .getService();
            } catch (Exception se) {
                System.out.println("--- START ERROR WITH SETTING STORAGE OBJECT ---");
                se.printStackTrace();
                System.out.println("--- END ERROR WITH SETTING STORAGE OBJECT ---");
            }

            // Modify access list to allow all users with link to read file
            acls = new ArrayList<>();
            acls.add(Acl.of(Acl.User.ofAllUsers(), Acl.Role.READER));

            try {
                Logger.info("GoogleControl: sendFileToBucket: Setting Blob object...");
                blob = storage.create(BlobInfo.newBuilder(BUCKET_NAME, fileName).setAcl(acls).build(), fileStream);
                Logger.info("GoogleControl: sendFileToBucket: Blob Object set...");
            } catch (Exception se) {
                System.out.println("--- START ERROR WITH SETTING BLOB OBJECT ---");
                se.printStackTrace();
                System.out.println("--- END ERROR WITH SETTING BLOB OBJECT ---");
            }

            Logger.info("GoogleControl: sendFileToBucket: blob.getMediaLink() = " + blob.getMediaLink());

            // Let's build a java.io.file to send back...
            returnFile = createFileFromURL(blob.getMediaLink(), fileName);

        } catch (Exception ex) {
            System.out.println("--- START ERROR SENDFILETOBUCKET ---");
            ex.printStackTrace();
            System.out.println("--- END ERROR SENDFILETOBUCKET ---");
        }
        return returnFile;
        // return outputFileName;
    }

    public static String uploadFile(java.io.File file, String folderIDToFind) throws IOException {
        String fileID = "";
        String fileName = "";
        try {
            Logger.info("GoogleControl: uploadFile: Starting File Upload...");
            // Build a new authorized API client service.
            Drive service = getDriveService();
            Logger.info("GoogleControl: uploadFile: Completed Drive Service...");

            // Set the folder...
            String folderID = Configuration.root().getString("google.drive.folderid");
            Logger.info("GoogleControl: uploadFile: Folder ID = " + folderID);

            String folderIDToUse = getSubfolderID(service, folderID, folderIDToFind);

            String fullFilePath = file.getAbsolutePath();
            Logger.info("GoogleControl: uploadFile: Full File Path: " + fullFilePath);
            File fileMetadata = new File();

            // Let's see what slashes exist to get the correct file name...
            if (fullFilePath.contains("/")) {
                fileName = StringControl.rightBack(fullFilePath, "/");
            } else {
                fileName = StringControl.rightBack(fullFilePath, "\\");
            }
            String fileContentType = getContentType(fileName);
            Logger.info("GoogleControl: uploadFile: File Content Type: " + fileContentType);
            fileMetadata.setName(fileName);
            Logger.info("GoogleControl: uploadFile: File Name = " + fileName);

            Logger.info("GoogleControl: uploadFile: Setting the folder...");
            fileMetadata.setParents(Collections.singletonList(folderIDToUse));
            Logger.info("GoogleControl: uploadFile: Folder set...");

            // Team Drive settings...
            fileMetadata.set("supportsTeamDrives", true);

            FileContent mediaContent = new FileContent(fileContentType, file);

            File fileToUpload = service.files().create(fileMetadata, mediaContent).setSupportsTeamDrives(true)
                    .setFields("id, parents").execute();

            fileID = fileToUpload.getId();
            Logger.info("GoogleControl: uploadFile: File ID: " + fileID);
        } catch (Exception ex) {
            System.out.println(ex.toString());
            ex.printStackTrace();
        }
        Logger.info("GoogleControl: uploadFile: Ending File Upload...");
        return fileID;
    }

}

Here is the code snippet that starts it all off: 这是所有代码的开始:

try {
    Logger.info("AdultPTPController: Starting File Upload...");
    File file = null;
    File fileFinal = null;
    String fileName = "";
    String fileContentType = "";
    String filePath = "";
    String fileID = "";
    String bucketFilePath = "";
    String bucketFileName = "";
    // String folderIDToFind =
    // adultDemo.getNew_Provider_Id().toString();
    String folderIDToFind = adultDemo.getLegacy_Provider_Id().toString();
    Http.MultipartFormData<File> formData = request().body().asMultipartFormData();
    if (formData != null) {
        Http.MultipartFormData.FilePart<File> filePart = formData.getFile("fileAttach");
        if (filePart != null) {
            fileName = filePart.getFilename().trim();
            // Is there a file?
            if (!fileName.equals("") && fileName != null) {
                Logger.info("AdultPTPController: File Name = " + fileName);
                fileContentType = filePart.getContentType();
                file = filePart.getFile();
                long size = Files.size(file.toPath());
                String fullFilePath = file.getPath();
                InputStream fileStream = new FileInputStream(fullFilePath);
                // Send the file/multipart content to the storage
                // bucket...
                Logger.info("AdultPTPController: Sending file to GoogleStorage - sendFileToBucket");
                File bucketFile = GoogleControl.sendFileToBucket(fileStream, fileName);
                //File bucketFile = null;
                Logger.info("AdultPTPController: File Sent to GoogleStorage - sendFileToBucket");

                // Send the file to Google Drive...
                if (bucketFile != null) {
                    // Upload the file and return the file ID...                            
                    Logger.info("AdultPTPController: File is not null, sending to uploadFile...");
                    bucketFileName = bucketFile.getName();
                    Logger.info("AdultPTPController: bucketFileName = " + bucketFileName);
                    fileID = GoogleControl.uploadFile(bucketFile, folderIDToFind);
                    Logger.info("AdultPTPController: File ID = " + fileID);
                    if (!fileID.equals("")) {
                        // Success...
                        // Create a file record...
                        FileUpload fileUpload = new FileUpload();
                        // Create a unique ID...
                        fileUpload.setFileKey(fileUpload.createFileKey());
                        // Set the needed fields...
                        fileUpload.setRecordID(adultDemo.getLegacy_Provider_Id().toString());
                        fileUpload.setRecordKey(adultPTP.getPtpkey());
                        fileUpload.setCreatedBy(user.getFullname());
                        fileUpload.setCreatedByEmail(user.getEmail());
                        fileUpload.setCreatedByKey(user.getUserkey());
                        fileUpload.setCreatedDate(GlobalUtilities.getCurrentLocalDateTime());
                        fileUpload.setDateCreatedDisplay(
                                GlobalUtilities.getStringDate(fileUpload.getCreatedDate()));
                        // Set the file info...
                        fileUpload.setFileID(fileID);
                        fileUpload.setFileName(fileName);
                        fileUpload.setFilePath(filePath);
                        String folderID = Configuration.root().getString("google.drive.folderid");
                        fileUpload.setFolderID(folderID);
                        // Set the URL...
                        String urlString = Configuration.root().getString("server.hostname");
                        String fullURL = urlString + "/downloadfile?ptpKey=" + adultPTP.getPtpkey() + "&fileID="
                                + fileID;
                        fileUpload.setFileURL(fullURL);
                        fileUpload.save();
                    }
                }
            }
        }
    }
} catch (Exception e) {
    e.printStackTrace();
}

I hope this helps the next guy. 我希望这对下一个家伙有帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用java将文件从谷歌应用引擎上传到谷歌驱动器 - Upload file from google app engine to google drive using java 通过Google App Engine(Java)将文件上传到Google云端存储 - Upload file to Google cloud storage from Google App Engine (Java) 从App Engine Java将urlconnection文件保存到Google云存储 - saving a urlconnection file to google cloud storage from app engine java 适用于Java和Google云存储的Google App Engine - Google App Engine for Java and Google Cloud Storage 使用blobstore api从云存储中检索文件的Google App引擎Java错误 - google app engine java error using blobstore api to retrieve file from cloud storage 使用 Java 通过 Google App Engine 将文件上传到 Google Cloud Storage:(没有这样的文件或目录) - Uploading Files to Google Cloud Storage via Google App Engine using Java: (No such file or directory) 通过Google App Engine(JAVA)将文件(图像或视频)从JSP上传到Google云存储 - Upload File (image or video) from JSP to google cloud storage via Google app engine(JAVA) 401 在使用 Micronaut java 创建谷歌存储桶时未经授权 - 401 unauthorised while creating google storage bucket using Micronaut java 使用谷歌云存储库在谷歌存储桶中移动 blob - Move blob within google bucket using google cloud storage library 从Java Google App引擎(Servlet)获取访问Google电子表格(保存到Google云端硬盘帐户中) - Get access google spreadsheet (saved into google drive account) from a java google app engine (servlet)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM