[英]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:
存储桶内有两个文件夹:
index.html
file index.html
文件 .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
文件?
<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>
`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.