1

ブロブストア API を使用しようとしていますが、次のエラーが発生します。

com.google.api.server.spi.SystemService invokeServiceMethod: バックアップされたメソッドの呼び出し中に例外が発生しました com.google.apphosting.api.ApiProxy$CallNotFoundException: API パッケージ 'file' または呼び出し 'Create()' が見つかりませんでした。java.lang.Thread.getStackTrace(Thread.java:1589) で com.google.apphosting.api.ApiProxy.makeSyncCall(ApiProxy.java:116) で com.google.apphosting.api.ApiProxy.makeSyncCall(ApiProxy.java) で:65) com.google.appengine.api.files.FileServiceImpl.makeSyncCall(FileServiceImpl.java:590) で com.google.appengine.api.files.FileServiceImpl.create(FileServiceImpl.java:512) で com.google. appengine.api.files.FileServiceImpl.createNewBlobFile(FileServiceImpl.java:111) com.listecourses.model.ListeModelEndpoint.insertListeModel(ListeModelEndpoint.java:182) で sun.reflect.

私はこのコードを使用しています:

@ApiMethod(name = "insertListeModel", httpMethod = "POST")
public ListeModel insertListeModel(ListeModel listemodel) {
    EntityManager mgr = getEntityManager();
    try {
        if (containsListeModel(listemodel)) {
            throw new EntityExistsException("Object already exists");
        }




        FileService fileService = FileServiceFactory.getFileService();
        if(listemodel.getImage()!=null && !listemodel.getImage().equals(""))
        {
            byte[] data = listemodel.getImage();




            String mimeType = "image/png";

            // save data to Google App Engine Blobstore 

            listemodel.setImage(null);
            mgr.persist(listemodel);
            AppEngineFile file;
                file = fileService.createNewBlobFile(mimeType,"LM_"+listemodel.getId());
                FileWriteChannel writeChannel = fileService.openWriteChannel(file, true);
                writeChannel.write(java.nio.ByteBuffer.wrap(data));
                writeChannel.closeFinally();

                // your blobKey to your data in Google App Engine BlobStore
                BlobKey blobKey = fileService.getBlobKey(file);

                // THANKS TO BLOBKEY YOU CAN GET FOR EXAMPLE SERVING URL FOR IMAGES

                //  UploadOptions uploadOptions = UploadOptions.Builder
                //          .withGoogleStorageBucketName("photobucket11");

                // Get the image serving URL (in https:// format)
                String imageUrl = ImagesServiceFactory.getImagesService().getServingUrl(ServingUrlOptions.Builder.withBlobKey(blobKey).secureUrl(true));

                //       ImagesService imagesService = ImagesServiceFactory
                //               .getImagesService();
                //      ServingUrlOptions servingOptions = ServingUrlOptions.Builder
                //               .withBlobKey(blobKey);

                //       String imageUrl = imagesService.getServingUrl(servingOptions);

                if(listemodel.getIdBlobkey()!=null)
                {
                    BlobKey blobKeytmp= new BlobKey(listemodel.getIdBlobkey());
                    final AppEngineFile f = fileService.getBlobFile(blobKeytmp);

                    if(f.isReadable())
                    {

                        if(f.hasFinalizedName())
                        {
                            fileService.delete(f); // Problematic line
                        }
                    }

                }

                listemodel.setAvatar(imageUrl);
                listemodel.setIdBlobkey(blobKey.getKeyString());
        }

                mgr.persist(listemodel);
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();


            } finally {
                mgr.close();
            }
            return listemodel;
        }

手伝って頂けますか?

4

1 に答える 1

0

files API は 2013 年に廃止され、今年ついに無効になったようです。参照: https://cloud.google.com/appengine/docs/deprecations/files_api

于 2015-10-24T19:54:41.860 に答える