简体   繁体   English

使用nodejs和id3打开文件的问题

[英]Problems with opening files using nodejs and id3

I'm having problems opening files with certain characters in nodejs using id3js. 我在使用id3js在nodejs中使用某些字符打开文件时遇到问题。

The file i'm trying to read is "14 What'z Ya Phone # (Feat. Danny Bo.mp3" 我要读取的文件是"14 What'z Ya Phone # (Feat. Danny Bo.mp3"

The error i'm getting is /14%20What'z%20Ya%20Phone%20 net::ERR_FILE_NOT_FOUND 我得到的错误是/14%20What'z%20Ya%20Phone%20 net::ERR_FILE_NOT_FOUND

As you can see, its cutting off at # in the original file name. 如您所见,它以原始文件名中的#开头。 What steps do i have to take to make sure node uses the entire filename when looking for the file. 查找文件时,我必须采取什么步骤来确保节点使用整个文件名。

There are some classic characters that should not be in urls. 有些经典字符不应该出现在url中。 Examples are: ? 例如: # @ / \\ : and %. #@ / \\:和%。 I think / and \\ are obvious why not (file paths). 我认为/和\\很明显为什么不(文件路径)。 ? is used for get requests. 用于获取请求。 # is used as an shortcut to an id on a page. #用作页面ID的快捷方式。 An email-address uses @'s, also ftp can use @. 电子邮件地址使用@,ftp也可以使用@。 You can specify a port in a url bij :. 您可以在URL bij:中指定端口。 % is used for url encodings. %用于URL编码。

These characters escaping will probably work, (most of those characters aren't allowed in filenames by your filesystem): 这些字符转义可能会起作用,(文件系统不允许在文件名中使用大多数字符):

? -> %3F
# -> %23
@ -> %40
/ -> %2F
\ -> %5C
: -> %3A
% -> %25

In my linux mint I can rename a file to: '?#@:\\.txt'. 在我的Linux Mint中,我可以将文件重命名为:'?#@:\\。txt'。 You can experiment which characters you need te replace. 您可以尝试替换哪些字符。

Note If you're replacing in javascript don't forget to set a global flag: "".replace(/\\?/g, "%3F") . 注意如果要替换为javascript,请不要忘记设置全局标志: "".replace(/\\?/g, "%3F")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 打开 blob 文件的问题 - Problems with opening blob files 使用JavaScript从ID3图像数据显示图像 - Display image from ID3 image data using javascript 使用 javascript 从 mp3 读取 id3 标签 - read id3 tags from mp3 using javascript 循环遍历 mp3 文件名数组并将 id3 标签提取到 nodejs 中的另一个数组 - Loop through array of mp3 filenames and extract id3 tags in to another array in nodejs 通过javascript从文件夹中的mp3文件中读取id3标签 - Read id3 tags from mp3 files in a folder through javascript 通过浏览器使用 javascript/jQuery 读取和写入 ID3 标签到本地文件? - Read AND write ID3 tags to local files with javascript/jQuery via browser? 如何使用javascript获取Windows 8 Metro应用程序中mp3文件的文件名和id3标签? - How to get the file name and id3 tags of an mp3 file in a Windows 8 metro app using javascript? HTTP Live Streaming:如何在iOS8中使用Javascript监听嵌入为ID3标签的定时元数据? - HTTP Live Streaming: how to listen for timed metadata embedded as ID3 tags using Javascript in iOS8? 使用(.reportValidity)后打开Bootstrap Modal时出现问题 - Problems opening Bootstrap Modal after using (.reportValidity) 带id的createElement(input);带计数器,Id1,Id2,Id3 - createElement (input) with Id ;with counter ,Id1,Id2,Id3
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM