对下载的 S3 映像的 URI 进行编码



我在 AWS S3 服务器上上传了一张图像,路径如下:https://dummy_momain/FeetPort/277/294/93/harwindersingh/2015-07-24/harwindersingh_2015-07-24_15:03:34:0660.jpeg

当我使用 S3 浏览器下载它时。 它下载图像并将其转换为以下格式:http://192.168.21.145/277/93/harwindersingh/2015-07-24/harwindersingh_2015-07-24_15%253A03%253A34%253A0660.jpeg

当我使用javascript函数escape,encodeURIencodeURIComponent时,它将路径转换为:http://192.168.21.145/277/93/harwindersingh/2015-07-24/harwindersingh_2015-07-24_15%3A03%3A34%3A0660.jpeg

两个字符串都没有处理。 我需要转换方面的帮助

harwindersingh_2015-07-24_15:03:34:0660.jpeg 转换为 harwindersingh_2015-07-24_15%253A03%253A34%253A0660.jpeg 格式。

看起来如果你做两次encodeURIComponent,你可以做到这一点。我认为在上传和下载的过程中,编码发生了两次。

var string = encodeURIComponent(encodeURIComponent('harwindersingh_2015-07-24_15:03:34:0660.jpeg'));
document.getElementById('a').innerHTML = string;
<div id="a"></div>