gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-27 23:25:57 25 4
gpt4 key购买 nike

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

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com