简体   繁体   English

上传到S3存储桶

[英]upload to S3 bucket

I am new to Elastic Beanstalk, just uploaded an NodeJs app. 我是Elastic Beanstalk的新手,刚刚上载了NodeJs应用程序。 I'm wondering if it's possible to "link" (like unix symlinks) a folder to a S3 bucket? 我想知道是否可以将文件夹“链接”(如unix符号链接)到S3存储桶?

Make "/recordings" points to S3: 使“ / recording”指向S3:

var filename = 'recordings/' + match[1] + '.wav';
      var file = fs.createWriteStream(filename);
      var request = https.get(url, function(response) {
          response.pipe(file);
          file.on('finish', function() {
            file.close();
      }).on('error', function(err) {
        fs.unlink(file);
        console.log('error downloading recording');
      });

You can use tools like s3fs-fuse to mount S3 buckets to your filesystem. 可以使用s3fs-fuse之类的工具将S3存储桶安装到文件系统中。 However, this is generally not recommended as S3 is not designed to be used as a block storage device. 但是,通常不建议这样做,因为S3并非旨在用作块存储设备。

As the s3fs readme documents: 作为s3fs自述文件:

Generally S3 cannot offer the same performance or semantics as a local file system. 通常,S3无法提供与本地文件系统相同的性能或语义。 More specifically: 进一步来说:

  • random writes or appends to files require rewriting the entire file 随机写入或追加到文件需要重写整个文件
  • metadata operations such as listing directories have poor performance due to network latency 元数据操作(例如列出目录)由于网络延迟而导致性能不佳
  • eventual consistency can temporarily yield stale data no atomic renames of files or directories 最终的一致性可以暂时产生陈旧的数据,而无需原子重命名文件或目录
  • no coordination between multiple clients mounting the same bucket 安装同一存储桶的多个客户端之间没有协调
  • no hard links 没有硬链接

The best way to use S3 with your Node application is using the AWS SDK for JavaScript in Node.js . 将S3与Node应用程序一起使用的最佳方法是在Node.js中使用适用于JavaScriptAWS开发工具包

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM