I have upload a attachment with Chinese name, but it shows like "*???*", I use VBA to do that as following code (everything can worked except filename display error):
And this attachment Excel have macro, so i changed header "Content-Type: application/vnd.ms-excel.sheet.binary.macroEnabled.12", "StrConv(srcTxt, vbFromUnicode, 1033)", "1033"(en-us) i have try change to "2050"(zh-cn), but the attachment with macro can't be open.
help~~
Private Function sendAttachmentToJira(ByVal sPostData As String) As Boolean
Dim sFileDataStr As String
Const STR_BOUNDARY_U As String = "abc123-xyz123"
JiraSite = "https://ocoejira.johnsoncontrols.com"
JIRAuser = Sheet1.Range("B3").Value
JIRApassword = Sheet1.Range("B4").Value
sFileDataStr = "--" & STR_BOUNDARY_U & vbCrLf & _
"Content-Disposition: form-data; name=""file"";Filename = """ & Mid$(sPostData, InStrRev(sPostData, "\") + 1) & """" & vbCrLf & _
"Content-Type: application/vnd.ms-excel.sheet.binary.macroEnabled.12" & vbCrLf & _
vbCrLf & getFileBytes(sPostData) & vbCrLf & "--" & _
STR_BOUNDARY_U & "--"
'Content-Type: multipart/form-data
With JiraService
.Open "POST", JiraSite & "/rest/api/2/issue/" & issueKey & "/attachments", False
.setRequestHeader "X-Atlassian-Token", "nocheck"
.setRequestHeader "Content-Type", "multipart/form-data ; boundary=" & STR_BOUNDARY_U 'application/json
.setRequestHeader "Authorization", "Basic " & EncodeBase64(JIRAuser & ":" & JIRApassword)
' .SetRequestHeader "Set-Cookie", Token
.send stringToByteArray(sFileDataStr)
JIRAResponse = .responseText
If .Status = "200" Then sendAttachmentToJira = True
End With
ErrHander:
If Left(JiraService.Status, 1) = "4" Then MsgBox removeBrackets(JIRAResponse), vbCritical, "Adding attachments failed...": sendAttachmentToJira = False
End Function
Private Function stringToByteArray(srcTxt As String) As Byte()
stringToByteArray = StrConv(srcTxt, vbFromUnicode, 1033)
End Function
so.... no one else had the same problem? ...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.