简体   繁体   English

将文件从存储桶的一个文件夹访问到AWS S3中同一存储桶的另一个文件夹

[英]Access file from one folder of a bucket to another folder of the same bucket in AWS S3

I have an Amazon S3 bucket. 我有一个Amazon S3存储桶。 Inside the bucket are two folders: 存储桶内有两个文件夹:

  • In the first folder there is an index.html file 在第一个文件夹中有一个index.html文件
  • In the second bucket there is a .js file 在第二个存储桶中有一个.js文件

How do I access the .js file in the second bucket from the index.html file in first bucket? 如何从第一个存储桶中的index.html文件访问第二个存储桶中的.js文件?

index.html index.html

<html>
 <head>
    <script type="text/javascript" src="/folder2/array.js"></script>
 </head>
 <body>
    <input type="button" onclick="go()" value="Display JS Array"/>
    <script>
        go();
    </script>
 </body>
</html>

array.js array.js

`function go(){
 var array = new Array();
 array[0] = "Red";
 array[1] = "Blue";
 array[3] = "Green";
 for (var i=0; i < array.length; i++){
    document.write("<li>" + array[i] + "<br />");
 }
}`

You could use the full path to the file. 您可以使用文件的完整路径

For example, if your bucket is called bucket-name-2 and is in the Sydney region, the link to the .js file would be: 例如,如果您的存储桶名为bucket-name-2 ,并且位于悉尼地区,则指向.js文件的链接为:

https://s3-ap-southeast-2.amazonaws.com/bucket-name-2/array.js

(These URLs are displayed in the Amazon S3 management console.) (这些URL显示在Amazon S3管理控制台中。)

If both buckets are in the same region, you could probably refer to the file via: 如果两个存储桶都在同一区域,则可以通过以下方式引用文件:

src=/bucket-name-2/array.js

This is because they would share the same DNS name, but would vary on the bucket name. 这是因为它们将共享相同的DNS名称,但存储桶名称会有所不同。

If you have activated static website hosting , the URL would look like: 如果您已激活静态网站托管 ,则URL如下所示:

http://my-bucket.s3-website-ap-southeast-2.amazonaws.com/array.js

暂无
暂无

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

相关问题 如何使用 Lambda 将文件从一个文件夹移动到同一 AWS S3 存储桶中的另一个文件夹? - How to move a File from One folder to Another Folder in the same AWS S3 bucket using Lambda? 如何将数据从一个 AWS S3 文件夹复制到同一存储桶中的另一个文件夹? - How to copy data from one AWS S3 folder to another folder in the same bucket? 如何在 Ruby 中将所有文件和子文件夹从一个文件夹复制到同一 AWS S3 存储桶中的另一个文件夹 - How do I copy all Files and Sub-Folders from One Folder to another Folder in same AWS S3 bucket in Ruby 将文件从一个文件夹复制到同一存储桶 NODE JS 的 s3 中的另一个文件夹 - Copying files from one folder to another folder in s3 of same bucket NODE JS 如何将所有文件从一个文件夹复制到同一个 S3 存储桶中的另一个文件夹 - How to copy all files from one folder to another folder in the same S3 bucket 将S3中的对象从一个文件夹复制到同一存储桶中的另一个文件夹 - Copy an Object in S3 from one folder to another folder in same bucket 将对象从一个 s3 文件夹移动到同一存储桶中的另一个文件夹的最快且最具成本效益的方法是什么 - what is the fastest and cost efficient way of moving objects from one s3 folder to another folder in same bucket 将 S3 存储桶中给定文件的所有版本从一个文件夹移动到另一个文件夹 - Move all versions of a given file in a S3 bucket from one folder to another folder 将内容从一个 s3 对象/文件夹移动到同一个存储桶中的另一个的最佳方法? - Best way to move contents from one s3 object/folder to another within the same bucket? 在AWS中如何使用lambda函数将文件从一个s3存储桶复制到另一个s3存储桶 - In AWS how to Copy file from one s3 bucket to another s3 bucket using lambda function
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM