如何在cdn上上传多个文件?
我必须在 cdn 上上传网页
。比如说test.html,test.css,image1.jpg等。现在我正在将所有这些文件一一上传。我认为这效率不高。那么,是否可以将所有这些文件保存在文件夹
中,然后上传此文件夹
到cdn
上?如果是,那么我需要注意哪些参数。压缩文件夹有帮助吗?我正在使用python
。
提前致谢
I have to upload a webpage on cdn
. Say test.html, test.css, image1.jpg
etc. Now I am uploading
all these file one by one. I think which is not efficient. So, is it possible to keep all these files in folder
and then upload this folder
on the cdn
? If yes, then what parameters i need to take care about that. Does zipping the folder helpful? I am using python
.
Thanks in Advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您无法将文件上传到 CDN,因为 CDN 是一个计算机系统,其中包含放置在网络各个节点上的数据副本。
基本上你需要先将数据上传到某个地方;假设在您的网站或博客 (www.mywebsite.com/image.jpg) 上,然后设置 CDN 提供商(例如 Amazon CloudFront)从您的网站获取内容并通过其网络分发。
CDN 提供商将为您提供一个类似 blablabla.amazon.com 的链接,您可以使用它来传送内容。因此,您的 image.jpg 现在可以从 blablabla.amazon.com/image.jpg 访问。当用户尝试此链接时,CDN 提供商会将请求路由到最近的服务器以传送图像。
You cannot upload files to a CDN simply because a CDN is a system of computers containing copies of data placed at various nodes of a network.
Basically you need to upload the data somewhere first; let's say on your webiste or blog (www.mywebsite.com/image.jpg) and then set up a CDN provider(e.g Amazon CloudFront) to fetch the content from your website and distribute through its network.
The CDN provider will give you a link like blablabla.amazon.com that you can use to deliver the content . So your image.jpg will be accessible now from blablabla.amazon.com/image.jpg . When users will try this link the CDN provider will route the request to its closest server to deliver the image .
我认为您正在尝试通过 FTP 客户端或类似方式将网站的静态内容(不是用户上传的文件)上传到 CDN。
要实现批量上传,您可以将所有此类文件压缩到本地计算机上并上传到您的网络服务器。在网络服务器上解压缩文件并编写批处理脚本,利用 CDN API 在 CDN 容器中发送文件。
对于未来的新文件或修改文件,请编写另一个批处理脚本来获取所有新文件/修改文件并通过 CDN API 发送到 CDN 容器。
I think you are trying to upload the static content of your website (not the user uploaded files) to CDN via FTP client or something similar.
To achieve bulk upload you may ZIP all such files on local machine and upload to your webserver. Unzip files on webserver and write a batch script which utlize the CDN API to send files in CDN container.
For fulture new or modified files, write another batch script to grab all new/modified files and send to CDN container via CDN API.