Jump to content
Fivewin Brasil

Arquivo Binário


Tales Souza

Recommended Posts

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.pdf

Como faço para transformar o arquivo "boleto.pdf" no mesmo padrão --data-binary ?

Grato,

Tales Souza

Link to comment
Share on other sites

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

 

 


 

 

 

Link to comment
Share on other sites

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)
Link to comment
Share on other sites

  • 2 years later...

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()

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...