PowerBuilder
PowerBuilder
Pre-Allocate Server Space Before an FTP Upload (ALLO)
See more FTP Examples
Demonstrates the AllocateSize property, which sends the FTP ALLO command to pre-allocate disk space on the server before an upload. Set it to the size in bytes of the file about to be uploaded.
Background:
ALLO asks the server to reserve storage in advance, a requirement of certain legacy systems — older mainframes in particular — that need the exact file size up front to allocate a dataset. Modern servers allocate space dynamically and typically ignore or accept ALLO without needing it, so most applications never set this. Provide it only when targeting a host known to require pre-allocation.Chilkat PowerBuilder Downloads
integer li_rc
integer li_Success
oleobject loo_Ftp
li_Success = 0
loo_Ftp = create oleobject
li_rc = loo_Ftp.ConnectToNewObject("Chilkat.Ftp2")
if li_rc < 0 then
destroy loo_Ftp
MessageBox("Error","Connecting to COM object failed")
return
end if
loo_Ftp.Hostname = "ftp.example.com"
loo_Ftp.Username = "myFtpLogin"
// Normally you would not hard-code the password in source. You should instead obtain it
// from an interactive prompt, environment variable, or a secrets vault.
loo_Ftp.Password = "myPassword"
li_Success = loo_Ftp.Connect()
if li_Success = 0 then
Write-Debug loo_Ftp.LastErrorText
destroy loo_Ftp
return
end if
// AllocateSize sends the FTP ALLO command to pre-allocate disk space on the server before an
// upload. It is rarely needed -- mainly for certain legacy systems that require the exact size
// in advance -- since most servers allocate space dynamically. Set it to the size in bytes of
// the file about to be uploaded.
ERROR: Assignment type mismatch. ExpressionType=int, atgType=uint
li_Success = loo_Ftp.PutFile("qa_data/bigfile.zip","uploads/bigfile.zip")
if li_Success = 0 then
Write-Debug loo_Ftp.LastErrorText
destroy loo_Ftp
return
end if
Write-Debug "Uploaded with pre-allocation."
li_Success = loo_Ftp.Disconnect()
if li_Success = 0 then
Write-Debug loo_Ftp.LastErrorText
destroy loo_Ftp
return
end if
destroy loo_Ftp