Tales Souza Posted September 14, 2021 Report Share Posted September 14, 2021 Boa tarde, senhores !!Eis o exemplo:curl -X POST https://content.dropboxapi.com/2/files/upload \--header "Authorization: Bearer " \--header "Dropbox-API-Arg: {\"path\": \"/Homework/math/Matrices.txt\",\"mode\": \"add\",\"autorename\": true,\"mute\": false,\"strict_conflict\": false}" \--header "Content-Type: application/octet-stream" \--data-binary @boleto.pdfComo faço para transformar o arquivo "boleto.pdf" no mesmo padrão --data-binary ?Grato,Tales Souza Quote Link to comment Share on other sites More sharing options...
emotta Posted September 14, 2021 Report Share Posted September 14, 2021 tenta ai cString := MemoRead("boleto.pdf") cBase64 := HB_Base64Encode( cString, Len(cString ) ) O que vc precisa mandar é o conteudo da variavel cBase64 Veja se da certo pra vc Quote Link to comment Share on other sites More sharing options...
Tales Souza Posted September 14, 2021 Author Report Share Posted September 14, 2021 Boa tarde, emotta !! Já tentei assim, Tcrlf := chr(13)+chr(10) Taux_API_Arg = '{' Taux_API_Arg += '"path":"/codechain/extrato.pdf",' Taux_API_Arg += '"mode":"add",' Taux_API_Arg += '"autorename":true,' Taux_API_Arg += '"mute":false' Taux_API_Arg += '}' Taux_Arquivo = "C:\Onedrive\fontes\ManagerDropbox\extrato.pdf" Taux_Binario = hb_MemoRead(Taux_Arquivo) Taux_Binario = hb_base64encode(Taux_Binario) Taux_Binario = alltrim( CharRem( Tcrlf, Taux_Binario ) ) oHttp := CreateObject("MSXML2.ServerXMLHTTP.6.0") oHttp:Open("POST", "https://content.dropboxapi.com/2/files/upload", .f.) oHttp:setRequestHeader("Authorization","Bearer " + alltrim(Taux_Token) ) oHttp:setRequestHeader("Content-Type", "application/octet-stream") oHttp:setRequestHeader("Dropbox-API-Arg", Taux_API_Arg ) oHttp:Send(Taux_Binario) O arquivo vai corrompido. Mas se eu faço pelo Postman, em body e escolho Binary, vai correto !!! Tales Quote Link to comment Share on other sites More sharing options...
emotta Posted September 14, 2021 Report Share Posted September 14, 2021 tente assim: Tcrlf := chr(13)+chr(10) Taux_API_Arg = '{' Taux_API_Arg += '"path":"/codechain/extrato.pdf",' Taux_API_Arg += '"mode":"add",' Taux_API_Arg += '"autorename":true,' Taux_API_Arg += '"mute":false' Taux_API_Arg += '}' Taux_Arquivo = "C:\Onedrive\fontes\ManagerDropbox\extrato.pdf" Taux_Binario = MemoRead(Taux_Arquivo) Taux_Binario = hb_base64encode(Taux_Binario, Len(Taux_Binario)) oHttp := CreateObject("MSXML2.ServerXMLHTTP.6.0") oHttp:Open("POST", "https://content.dropboxapi.com/2/files/upload", .f.) oHttp:setRequestHeader("Authorization","Bearer " + alltrim(Taux_Token) ) oHttp:setRequestHeader("Content-Type", "application/octet-stream") oHttp:setRequestHeader("Dropbox-API-Arg", Taux_API_Arg ) oHttp:Send(Taux_Binario) Quote Link to comment Share on other sites More sharing options...
Tales Souza Posted September 14, 2021 Author Report Share Posted September 14, 2021 Emotta, Acabei de testar. Exatamente o mesmo erro. O arquivo até faz o upload, mas corrompido. Mas no Postman funciona. E são as memas informações. Tales Quote Link to comment Share on other sites More sharing options...
wanderlei Posted April 26 Report Share Posted April 26 Pessoal alguém conseguiu enviar arquivo para o DropBox? Quote Link to comment Share on other sites More sharing options...
rochinha Posted Wednesday at 01:46 PM Report Share Posted Wednesday at 01:46 PM Amiguinhos, Que tal tentar assim: oHttp := CreateObject("MSXML2.ServerXMLHTTP.6.0") oHttp:Open("POST", "https://content.dropboxapi.com/2/files/upload", .f.) oHttp:setRequestHeader( "Authorization", "Bearer " + alltrim(Taux_Token) ) oHttp:setRequestHeader( "Content-Length: " + str(len(Taux_Binario)) ) oHttp:setRequestHeader( "Content-Type", "application/pdf" ) oHttp:setRequestHeader( [Content-Disposition: form-data; name="arquivo"; filename="\temp\TestePZ.pdf" ] + Taux_Binario ) oHttp:setRequestHeader( "Dropbox-API-Arg", Taux_API_Arg ) oHttp:Send() Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.