Download image file using CURLSMBS

I am not using CURLSMBS ftp feature to download the file since the url is a https link

I am currently using URLConnection to download file from Airtable server using the following code without problem.

DIM c As String =tURL
DIM f As FolderItem = GetFolderItem("").child("ATDownloadImages").Child(AttachmentDict.Value("filename").StringValue)
DIM ht As New URLConnection
ht.AllowCertificateValidation = False
If c <> "" Then ht.Send("GET", c , f, 320)

I am researching doing the same thing using CURLSBS instead. the following is the code and I think I have something missing.

c.OptionCustomRequest = "GET"
c.SetOptionHTTPHeader Array(xBearer)
c.OptionURL = tURL
Dim Error As Integer = c.Perform

… any particular reason?

Are you getting an error number or message of some kind? There isn’t really a lot of context with what you’ve shared, so it’s difficult to have any suggestions.

@Christian_Schmitz has examples for nearly everything.
Maybe this will reveal your issue?

I never thought of that… saving the d.OutputData as the file.

let me try this and get back to you… I know I was missing something.

You can use CreateMTOutputFile function to stream directly to a file.

will try CreateMTOutputFile now

brilliant !! CreateMTOutputFile work… at first I put the code after the perform and wasn’t working. then I go the website and it say put the code before perform and it work brilliantly

The whole “MT” thing is not well-explained I find - when to use PerformMT instead of Perform, when it’s required to create MTInput and MTOutput files, what benefits it provides over non-MT transfers… then when you start using CURLSMultiMBS, which queues CURLSMBS objects, it’s even more vague. I recently started using the new features of CURLSMultiMBS, which are great, but only found out through trial and error that creation of an MTinputFile for each CURLSMBS is required for uploads (MTOutputFile is presumably required for downloads). And on top of that there’s the BinaryStream that shows up in some examples. The documentation doesn’t provide much info about these properties.

seem like I can use the MTInput and MTOutput even without PerformMT.

when should we use CURLSMultiMBS instead of CURLSMBS??

CURLSMultiMBS is for multiple files. I download external images for emails with CURLSMultiMBS.

This stuff is so old, that we have some historic there.

I started the CreateMTOutputFile and OpenMTInputFIle to stream data for PerformMT to avoid you needing the events to process data as needed. And we got the InputData and OutputData things to do similar for in memory.
And after years of progress, you can now mix them as needed. I could remove the MT from the CreateMTOutputFile and OpenMTInputFile names, but that may annoy people.

1 Like

If you’re downloading multiple files, as Beatrix said, not in a thread, and you want your app to stay responsive, CURLSMultiMBS is great, especially the latest version. You instantiate a CURLSMBS, add it to the Multi’s queue, pass a delegate to a TransferFinished handler, and go about your business. If I’m in a thread and the thread has nothing to do until a download is finished (say, a directory listing) then I’ll use just a blocking/synchronous CURLSMBS download.

Before I started using the Multi, I thought that using PerformMT instead of Perform might somehow magically do some multi-threading, but I never saw any performance difference.