CURLSMBS.FileInfos with Amazon S3

I want to get a directory listing from an S3 bucket, with filenames and modification dates, using SFTP. Here’s my setup, based on the MBS example:

curl.CollectDebugMessages = True
curl.CollectOutputData = False // or True, doesn't seem to matter
curl.OptionVerbose = True
curl.OptionDirListOnly = False
curl.OptionCustomRequest = "MLSD"
curl.OptionWildcardMatch = False

After the transfer, curl.OutputData looks like this:

-rwxr--r-- 1 - - 2971 Apr 21 16:00 My Filename Contains Spaces.xlsx

This is a pain to parse, and I have no idea how “2971” relates to the actual year 2024.

I thought FileInfos would be the answer, and indeed it does return an array, but all the fields are unpopulated :frowning:

Filezilla is somehow able to display all info including the full modification date to the second in its directory listing.

You get a directory listing in unix style.
Is it SFTP?

Well, then 2971 is the file size. The date is not included in this output.

Yes, SFTP, thanks.

Does anyone know how to get a parse-able directory listing with modification dates from an S3 bucket, using SFTP, with or without MBS?

My libssh2 binding can do that:

  Dim session As SSH.Session = SSH.Connect("ssh://")
  Dim sftp As New SSH.SFTPSession(session)
  Dim names() As String
  Dim dates() As Date
  Dim lister As SSH.SFTPDirectory = sftp.ListDirectory("/path/to/dir/")
  Loop Until Not lister.ReadNextEntry()


I don’t think curl/libcurl/curlmbs can do this over SFTP. They just return a directory listing like you’re already getting.


Thanks @Andrew_Lambert , I’ve been wanting to check out your libssh2 stuff for other reasons for a while and this will push me to dig in. One thing though, is that I don’t have user:password access, I have to use a key file, hopefully it can handle that.

1 Like

It can do password, key, or agent-mediated authentication.

1 Like