a5storage_copyFiles Function
Syntax
L result = a5storage_copyFiles(C connectionString, C sourceFolder [, C pattern [, C targetFolder [, N concurrentTasks [, P pResultIn [, L flagSetReadPermission [, L optimized]]]]]])
Arguments
- connectionStringCharacter
The storage connection string for the destination. This is typically an Amazon S3 or Wasabi storage connection string.
- sourceFolderCharacter
The source folder where the files to copy are stored. Can either be a folder name or a CR-LF delimited list of file names.
- patternCharacter
Default = "*.*". An optional filter pattern that specifies the files in the source folder to copy.
- targetFolderCharacter
Default = "". The folder in the target location where the files should be copied.
- concurrentTasksNumeric
Default = 100. The number of concurrent tasks that should be started to perform the copy. Choosing too high a number will negatively impact performance. If you set a number that exceeds the number of files to copy, the concurrentTasks is automatically reduced to the number of files to copy.
- pResultInPointer
Default = null_value(). An optional dot variable passed into the function that is populated with the following properties:
- timeTakenNumeric
How long it took to copy the files.
- numberOfFilesCopiedNumeric
The number of files copied.
- filesCharacter
A list of the files that were copied.
- concurrentTasksNumeric
The actual concurrent tasks setting used.
- errorLogical
Indicates whether or not an error occurred.
- errorTextCharacter
If an error occurred, contains an error message.
- flagSetReadPermissionLogical
Default = .f.. Only applies when target connection string points to an Amazon S3 bucket. If .t., sets the ACL on the files that are copied to allow read access.
- optimizedLogical
Default = .f.. If set to .t., only files that do not exist in the bucket are copied. This means existing files with the same name are not overwritten.
Returns
- resultLogical
Returns .t. if an error occurred. Otherwise, returns .f.. If an error occurs and you passed in a pointer variable for the pResultIn variable, the pResultIn.errorText contains information about the error.
Description
Copies a folder or list of files to Amazon S3, Wasabi, or other Amazon S3 compatible cloud storage services defined using a storage connection string.
Discussion
The a5storage_copyFiles() function is optimized to quickly upload multiple files to Amazon S3 or Wasabi storage. The function can copy an entire folder or comma delimited list of files.
An optional filter can be used to specify what files should be copied from a folder. For example, the Xbasic code below copies all .jpg files from a folder called "C:\myfiles" to the "images" folder in an Amazon S3 bucket, defined by the "myS3Bucket" storage connection string.
dim result as L result = a5storage_copyFiles("myS3Bucket","c:\myfiles","*.jpg","images",100) if (result) then ' copy successful else ' copy failed end if
See Also