我需要生成边界为多部分上传生成随机字符串,不SecureRandom的
post << "--#{BOUNDARY}\r\n"
post << "Content-Disposition: form-data; name=\"datafile\"; filename=\"#{filename}\"\r\n"
post << "Content-Type: text/plain\r\n"
post << "\r\n"
post << file
post << "\r\n--#{BOUNDARY}--\r\n"
边界需要是一个随机字符串(没有出现在文件中)。
在Rails,我可以做SecureRandom.hex(10)
谁,我可以做到这一点,无负载的ActiveSupport?
为什么它需要是随机的? – sepp2k 2010-08-07 17:07:16
我无法使用预先生成的边界字符串,因为如果我上传的文件包含字符串,我需要生成一个新字符串。 – 2010-08-07 17:13:52