Upload PDF file via API: Could someone explain what is going on?

40 Views Asked by At

I found this question and answer:

How to upload a pdf fil...

I have adapted solution to my needs. I use it for uploading pdf-files to a financial system and it is working just fine, but there is some code part I don't understand:

Dim FieldANme as string
---
Dim File, FILESIZE
Set ado = CreateObject("ADODB.Stream")
ado.Type = 1 'binary
ado.Open
ado.LoadFromFile FilePath
ado.Position = 0
FILESIZE = ado.Size
File = ado.Read
ado.Close

Set ado = CreateObject("ADODB.Stream")
d = "--" + BOUNDARY + vbCrLf
d = d + "Content-Disposition: form-data; name=""deal_id""" & vbCrLf & vbCrLf
d = d + DEALID & vbCrLf
d = d + "--" + BOUNDARY + vbCrLf
d = d + "Content-Disposition: form-data; name=""" + FieldName + """;"
d = d + " filename=""" + fileName + """" + vbCrLf
d = d + "Content-Type: " & CONTENT + vbCrLf + vbCrLf
ado.Type = 1 'binary
ado.Open
ado.Write ToBytes(d)
ado.Write File
ado.Write ToBytes(vbCrLf + "--" + BOUNDARY + "--" + vbCrLf)
ado.Position = 0

I have two questions:

  1. Dim FieldName As String: It is not used. What could it be used for?
  2. Could someone explain the ADODB stuff? I understand that the file is digitized - but a PDF file is per default digital?

I did search for explanations but didn't find an explanation.

0

There are 0 best solutions below