开发者

Base64 Encode - Decode Python and ASP.Net?

i m trying encode data on python with "base64.encodestring()" then i send encodedData to my asp.net service and trying decode this data.But this data is invalid.

Python function code () :

randomString=''.join(random.choice(string.ascii_uppercase + string.digits) for x in range(10))
fileNameString=randomString+"_"+request.vars['file'].filename
pathToFile开发者_如何学Go="/tmp/"+fileNameString
f = open(pathToFile,"wb")
f.write(request.vars["file"].file.read())
f.close()

f = open(pathToFile,"rb")
data=f.read()
f.close()
encodedData=base64.encodestring(data)

return encodedData

C# Code:

byte[] filebytes = Convert.FromBase64String(encodedData);
FileStream fs = new FileStream(crmPath + fileName,
FileMode.CreateNew,
FileAccess.Write,
FileShare.None);
fs.Write(filebytes, 0, filebytes.Length);
fs.Close();

this codes works towards save file but when i try to open this file it isnt opened

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜