当前位置: 首页 > 知识库问答 >
问题:

找不到API包“file”或调用“create()”

鲁英卫
2023-03-14

我使用以下代码:

@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;
        }

你能帮我吗?

暂时还没有答案

 类似资料:
  • 问题内容: 我正在尝试在GAE云中托管的GAE应用程序中调用Google服务: 执行抛出: 。 有任何想法吗?我完全迷路了… 问题答案: 您可以使用其他http客户端吗?如推荐这里: 还是使用URLFetchService呢? 根据此博客文章,您需要: “定制连接管理器,它将最终请求转换为URL提取服务,然后将响应反馈回HttpClient。”

  • 问题内容: 我收到以下错误: 在类路径资源[jpaDaoContext.xml]中定义的名称为’org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor#0’的bean创建时出错:bean的初始化失败;嵌套的异常是org.springframework.beans.factory.BeanCrea

  • 我的Groovy脚本连接到bitBuck API并获取分支详细信息。这是脚本: 但这抛出以下错误: 但是当我在浏览器上复制粘贴URL时,我能够看到JSON数据。如何使用Groovy从此URL获取JSON数据?

  • 我的java编译器找不到包。考虑: 使用编译 给出 我使用的是Ubuntu 12.04,我想我已经安装了JDK 7(参见:package java.nio.file不存在)

  • 当我尝试安装npm与,我得到以下错误: E:找不到包npm 为什么找不到npm?我正在使用Debian 9并且已经运行了

  • 所以我刚刚安装了Ubuntu,这是我第一次在Linux环境中工作,所以请容忍我的愚蠢。 无论如何,我直接从Oracle下载了Java8 JDK,但我知道还有一个用于Java8的OpenJDK。我有两个问题。 > Oracle版本和OpenJDK之间的区别是什么。赞成/反对? 我看到下面有一个链接,我打算在早上查看一下,现在是凌晨2点,我现在很累。任何其他的建议,这新的问题将是赞赏的,否则我肯定会检