Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/329.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用gae for java将数据存储到google云存储_Java_Google App Engine_Google Cloud Storage - Fatal编程技术网

使用gae for java将数据存储到google云存储

使用gae for java将数据存储到google云存储,java,google-app-engine,google-cloud-storage,Java,Google App Engine,Google Cloud Storage,我正在尝试将应用程序引擎应用程序中的数据存储到谷歌云存储 如果我在本地执行,代码运行良好,但我看不到存储任何数据 如果我将应用程序上载到应用程序引擎,则在以下位置运行代码时会出现空指针异常: AppEngineFile writeablefile=fileService.createNewGSFile(optionsBuilder.build()) 我使用的完整代码是 // Get the file service FileService fileService

我正在尝试将应用程序引擎应用程序中的数据存储到谷歌云存储

如果我在本地执行,代码运行良好,但我看不到存储任何数据

如果我将应用程序上载到应用程序引擎,则在以下位置运行代码时会出现空指针异常: AppEngineFile writeablefile=fileService.createNewGSFile(optionsBuilder.build())

我使用的完整代码是

        // Get the file service
        FileService fileService = FileServiceFactory.getFileService();

        /**
         * Set up properties of your new object
         * After finalizing objects, they are accessible
         * through Cloud Storage with the URL:
         * http://commondatastorage.googleapis.com/my_bucket/my_object
         */
        GSFileOptionsBuilder optionsBuilder = new GSFileOptionsBuilder()
          .setBucket("blood")
          .setKey("1234567")
          .setAcl("public-read")
          .setMimeType("text/html");//.setUserMetadata("date-created", "092011", "owner", "Jon");


        // Create your object
        AppEngineFile writableFile = fileService.createNewGSFile(optionsBuilder.build());

        // Open a channel for writing
        boolean lockForWrite = true; // Do you want to exclusively lock this object?
        FileWriteChannel writeChannel = fileService.openWriteChannel(writableFile, lockForWrite);
        // For this example, we write to the object using the PrintWriter
        PrintWriter out = new PrintWriter(Channels.newWriter(writeChannel, "UTF8"));
        out.println("The woods are lovely and deep.");
        out.println("But I have promises too keep.");

        // Close the object without finalizing.
        out.close();

        // Finalize the object
        writeChannel.closeFinally();
        System.out.println("Completed writing to google storage");

在Google Storage中使用dev服务和文件服务时,它实际上并不会写入您的Google存储桶,而是写入本地文件系统-您是否希望它写入Google存储


对于空指针异常,需要查看堆栈跟踪,以尝试缩小出错范围。

在Google Storage中使用dev服务和文件服务时,它实际上并不会写入您的Google Storage bucket,而是写入本地文件系统-您希望它写入Google Storage吗


对于空指针异常,需要查看堆栈跟踪,以尝试缩小错误范围。

因此,问题在于app engine无权读取/写入在云存储中创建的存储桶。

因此,问题在于app engine无权读取/写入在云存储中创建的存储桶。

您可以我们正在谈论BlobStore“内置”服务。谷歌云存储是开发环境和生产(appspot.com)的一项外部服务,您完全可以理解。那么,对这个问题有什么想法吗?我知道-当在app engine开发服务器上使用文件API时,它不会读取或写入外部Google存储服务,而是模拟它读取和写入本地磁盘。那么,你的意思是这是一个已知的问题吗?开发应用服务器没有写入实际的Google存储服务是出于设计-不是一个问题。你知道吗我们正在谈论BlobStore“内置”服务。谷歌云存储是开发环境和生产(appspot.com)的一项外部服务,您完全可以理解。关于这个问题有什么想法吗?我知道-当在app engine开发服务器上使用文件API时,它不会读取或写入外部Google存储服务,而是模仿它读取和写入本地磁盘。那么你的意思是这是一个已知的问题吗?dev appserver没有写入实际的Google存储服务是出于设计-不是一个问题。