[英]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.