Google App Engine 是否允许在服务器上创建文件和文件夹? [英] Does Google App Engine allow creation of files and folders on the server?

查看:31
本文介绍了Google App Engine 是否允许在服务器上创建文件和文件夹?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道 Google App Engine 提供免费空间,但我想知道它是否仅用于将数据存储在其数据库中,还是还允许我在服务器端创建文件和目录来存储我的数据?比如我可以用下面的方法来保存文件吗?

I know Google App Engine offers free space, but I wonder if it's for storing data in its database only or does it also allow me to create files and directories on the server side to store my data ? For instance can I use the following method to save file ?

  public static void saveFile(String File_Path,StringBuffer Str_Buf,boolean Append)
  {
    FileOutputStream fos=null;
    BufferedOutputStream bos=null;

    try
    {
      fos=new FileOutputStream(File_Path,Append);
      bos=new BufferedOutputStream(fos);
      for (int j=0;j<Str_Buf.length();j++) bos.write(Str_Buf.charAt(j));
    }
    catch (Exception e) { e.printStackTrace(); }
    finally
    {
      try 
      {
        if (bos!=null)
        {
          bos.close();
          bos=null;
        }
        if (fos!=null)
        {
          fos.close();
          fos=null;
        }
      }
      catch (Exception ex) { ex.printStackTrace(); }
    }
  }

推荐答案

您可以从自己的项目中读取文件 - 您无法写入文件系统

You can read files from your own project - You cannot write to the file system

来自常见问题...

由于应用程序的分布式特性,App Engine 不支持写入本地文件.相反,必须持久化的数据应该存储在分布式数据存储中.有关更多信息,请参阅有关运行时沙箱的文档

Writing to local files is not supported in App Engine due to the distributed nature of your application. Instead, data which must be persisted should be stored in the distributed datastore. For more information see the documentation on the runtime sandbox

  • 写入文件系统.应用程序必须使用 App Engine 数据存储区来存储持久数据.允许从文件系统读取,并且所有与应用程序一起上传的应用程序文件都可用.

  • write to the filesystem. Applications must use the App Engine datastore for storing persistent data. Reading from the filesystem is allowed, and all application files uploaded with the application are available.

打开一个套接字或直接访问另一个主机.应用程序可以使用 App Engine 网址提取服务分别向端口 80 和 443 上的其他主机发出 HTTP 和 HTTPS 请求.

open a socket or access another host directly. An application can use the App Engine URL fetch service to make HTTP and HTTPS requests to other hosts on ports 80 and 443, respectively.

产生一个子进程或线程.对应用程序的 Web 请求必须在几秒钟内在单个进程中处理.需要很长时间才能响应的进程将被终止,以避免网络服务器过载.

spawn a sub-process or thread. A web request to an application must be handled in a single process within a few seconds. Processes that take a very long time to respond are terminated to avoid overloading the web server.

进行其他类型的系统调用.

make other kinds of system calls.

这篇关于Google App Engine 是否允许在服务器上创建文件和文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆