javascript - 对 S3 下载的图像的 URI 进行编码

标签 javascript jquery url amazon-s3

我已使用以下路径在 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>

关于javascript - 对 S3 下载的图像的 URI 进行编码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34960959/

相关文章:

javascript - jquery:如何设置 First "child"在 Tree 中可见?

javascript - Jquery 没有按预期工作

html - 输入类型 URL - 如果不包含 HTTP,则为 "Please enter a URL"

java - 从链接获取 youtube id

javascript - 使用减号更改 url 中的空格

php - 条件下载页面内容(js、css)

javascript - 如何在 jQuery 中缩小和恢复 Div

javascript - 导出到 Excel/打印带网格线的 HTML 表格

jQuery 加载问题

jquery - 如何在 Foundation 6 中动态创建和删除选项卡?