上传PNG附件ALM 12.60其余版本

时间:2018-10-04 08:43:04

标签: image upload png hp-uft alm

早上好, 我正在尝试通过ALM Api rest上传图像(PNG)。 这是功能:

Function uploadFicheroALM(nombreScript, rutaFichero, executionId, value)
    leerConfiguracion
    readContextoEjecucion
    inicializarDatosALM
    nombreFichero = rutaFichero
    sBoundary = "--a123b"
    
    contenidoFichero = URLEncode(convertirBase64("C:/Users/User/Desktop/prueba.png"))
    
    requestUrl = almUrl&"/qcbin/rest/domains/"&almDominio&"/projects/"&almProyecto&"/runs/"&executionId&"/attachments"
    'vbCrLf = salto de linea
    auth = Base64Encode(almUser&":"&almPass)
    
    Set o = CreateObject("MSXML2.XMLHTTP")
    o.open "POST", requestUrl, false
    o.setRequestHeader "Authorization", "Basic "&auth
    o.setRequestHeader "Content-type", "multipart/form-data; boundary=a123b"
    
    'Description
    request = request & sBoundary & vbCrLf
    request = request & "Content-Disposition: form-data; name=""description""" & vbCrLf
    request = request & "Descripcion de prueba" & vbCrLf
    
    'File Name
    request = request & sBoundary & vbCrLf
    request = request & "Content-Disposition: form-data; name=""filename""" & vbCrLf & vbCrLf
    request = request & "prueba.png" & vbCrLf
    
    'File Name
    request = request & sBoundary & vbCrLf
    request = request & "Content-Disposition: form-data; name=""override-existing-attachment""" & vbCrLf
    request = request & "y" & vbCrLf
    
    'File
    request = request & sBoundary & vbCrLf
    request = request & "Content-Disposition: form-data; name=""file""" & vbCrLf & vbCrLf
    request = request & "Content-Transfer-Encoding: base64" & vbCrLf
    request = request & contenidoFichero & vbCrLf
    request = request & "--a123b--"
    
    o.send request
    
    respuesta = o.responseText 
End Function

它可以报告“描述”,“文件名”和“图像”,如您在捕获中看到的那样:

Error to open the image

但是,如果我打开图片时显示“未知文件错误”,有人可以帮我吗?,谢谢。

0 个答案:

没有答案