我已使用以下路径在 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,encodeURI 和 encodeURIComponent 时,它将路径转换为: 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>
关于javascript - 对 S3 下载的图像的 URI 进行编码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34960959/