GetAttachment
Mon 01 January 2018Syntax
GetAttachment(URLSource, DirAndSysFileName, DirAndLocalFileName[, LocalDirEnvVar[, PreserveCase]])
Description
Use the GetAttachment function to download a file from its source storage location to the file system of the application server. The file system of the application server includes any directories accessible from the application server including those on local disks as well as on network shares.
Note: All directories that are part of the destination full path name must exist before GetAttachment is called. The GetAttachment function will not create any directories on the application server's file system.
Additional information that is important to the use of GetAttachment can be found in the PeopleTools: PeopleCode Developer's Guide :
-
PeopleTools supports multiple types of storage locations.
See .
-
Certain characters are illegal in file names; other characters in file names are converted during file transfer.
See .
-
Non-ASCII file names are supported by the PeopleCode file attachment functions.
See .
-
The PeopleCode file attachment functions do not provide text file conversions when files are attached or viewed.
See .
Parameters
Field or Control |
Definition |
---|---|
URLSource |
A reference to a URL. This can be either a URL identifier the form URL. URL_ID , or a string. This (along with the DirAndSysFileName parameter) indicates the file's source location. Note: When the URLSource parameter is specified as a string value, forward slashes (/) are required. Backward slashes (\) are not supported for a string value. See . |
DirAndSysFileName |
The relative path and file name of the file at the storage location. This is appended to URLSource to form the full URL where the file will be transferred from. This parameter takes a string value. Note: Because the DirAndSysFileName parameter is appended to the URL, it also requires forward slashes (â/â). Backward slashes (â\â) are not supported for this parameter. |
DirAndLocalFileName |
The name, relative path name, or full path name of the destination file on the application server. This parameter takes a string value. If you specify only a name or a relative path name for the destination file, the file will be placed in or relative to:
If you do not want to use the LocalDirEnvVar parameter or the value of the TMP environment variable in this way, you must specify a full path name as appropriate to the application serverâs operating system. |
LocalDirEnvVar |
This optional parameter takes a string value. If LocalDirEnvVar is specified, then its value will be prefixed to the value of the DirAndLocalFileName parameter to form the full path name of the destination file on the application serverâs file system. With this parameter, you can avoid the need to hard-code the full path name. If LocalDirEnvVar is not specified and the value of the DirAndLocalFileName parameter is already a full path file name, then that value will itself be used as the full path name that the downloaded file will have at its destination on the application server machine. If LocalDirEnvVar is not specified and the value of the DirAndLocalFileName parameter is not a full path file name, then the value of the TMP environment variable will be prefixed to the value of the DirAndLocalFileName parameter to form the full path name that the downloaded file will have at its destination on the application server machine. Note: In order to use the optional parameter PreserveCase, you must pass some value for LocalDirEnvVar. If you want to use the default behavior of LocalDirEnvVar and also use PreserveCase, you can specify "" (the empty string) for LocalDirEnvVar . Then the function behaves as if no value is specified. In this situation, if you wish to use the TMP environment variable, it must be explicitly specified. Note: Do not specify LocalDirEnvVar if you use an absolute path for the DirAndLocalFileName parameter. |
PreserveCase |
When searching for the file specified by the DirAndSysFileName parameter, PreserveCase specifies a Boolean value to indicate whether the case of its file name extension is preserved: True, preserve the case, False, convert the file name extension in DirAndSysFileName to all lowercase letters. The default value is False. For a particular file, use the same value for this parameter that was used when the file was originally uploaded. Warning! If you use the PreserveCase parameter, it is important that you use it in a consistent manner with all the relevant file-processing functions or you may encounter unexpected file-not-found errors. This is an optional parameter. |
Returns
You can check for either an integer or a constant value:
Numeric Value |
Constant Value |
Description |
---|---|---|
0 |
%Attachment_Success |
File was transferred successfully. |
1 |
%Attachment_Failed |
File transfer failed due to unspecified error. The following are some possible situations where %Attachment_Failed could be returned:
|
3 |
%Attachment_FileTransferFailed |
File transfer failed due to unspecified error during FTP attempt. The following are some possible situations where %Attachment_FileTransferFailed could be returned:
|
4 |
%Attachment_NoDiskSpaceAppServ |
No disk space on the application server. |
7 |
%Attachment_DestSystNotFound |
Cannot locate destination system for FTP.
|
8 |
%Attachment_DestSysFailedLogin |
Unable to login to destination system for FTP. The following are some possible situations where %Attachment_DestSysFailedLogin could be returned:
|
9 |
%Attachment_FileNotFound |
Cannot locate file. The following are some possible situations where %Attachment_FileNotFound could be returned:
|