UploadAttachment
添付ファイルをアップロードし、特定のSalesforce レコードに関連付けます。
Stored Procedure-Specific Information
This stored procedure uploads a ContentDocument (Salesforce Files) to Salesforce.In the following examples:
- Title is the title for the uploaded content document.
- FileExtension is the file extension (e.g., 'txt', 'pdf', 'png').
- FullPath is the full path to the file to upload.
- Base64Data is Base64-encoded file content.
Examples
To upload a content document (test_UploadDocumentContent_stream):
EXEC UploadContentDocument Title = 'testing', FileExtension = 'txt'To upload a content document with a file path:
EXEC UploadContentDocument FullPath = 'C:\Documents\myfile.pdf'To upload a content document with Base64 data:
EXEC UploadContentDocument Base64Data = 'byBib2Jl', Title = 'mydocument', FileExtension = 'txt'
Uploading Single Files or Single Folders
To upload a single attachment, specify the FullPath:EXEC UploadAttachment ObjectId = '0018Z00002nz4TkMAR', FullPath = 'C:\\csv samples\\mycsvfile.csv'To upload all attachments in a single folder, use FolderPath:
EXEC UploadAttachment ObjectId = '0018Z00002nz4TkMAR', FolderPath = 'C:\\csv samples'For Base64 data, you need to specify the Base64Data, Title, and FileExtension:
EXEC UploadAttachment ObjectId = '0018Z00002nz4TkMAR', Base64Data = 'byBib2Jl', Title = 't', FileExtension = 'txt'
Uploading Multi-Valued Inputs
There are various ways to upload multiple files or folders. One way is to use a temporary table, #TEMP:- First insert values into temporary tables. For example:
INSERT INTO Attachment#TEMP (ObjectId, FolderPath) VALUES ( '0018Z00002nz4TkMAR', 'C:\\TestImages' ) INSERT INTO Attachment#TEMP (ObjectId, FolderPath) VALUES ('0018Z00002nz4TkMAR', 'C:\\csv samples' )This inserts the values into a table in memory. - Then reference that same table when executing the stored procedure:
EXEC UploadAttachment Attachments = 'Attachment#TEMP'
This approach has the advantage of avoiding arbitrary parameters as inputs to the stored procedure.
Input
| Name | Type | Accepts Input Streams | Description |
| ObjectId | String | False | アップロードされたファイルを関連付けるSalesforce オブジェクト(取引先や商談など)のID。この項目は必須です。 |
| FullPath | String | False | ローカルシステムからアップロードするドキュメントの完全なファイルパス。Base64Data が提供されていない場合は必須です。アップロードごとにFullPath またはFolderPath のいずれか1つのみを指定してください。 |
| Base64Data | String | False | Base64 エンコードされたファイルの完全なコンテンツ。FullPath が提供されていない場合は必須です。ファイルシステムアクセスなしのプログラムアップロードに有用です。 |
| FileName | String | False | アップロードされた添付ファイルに割り当てる名前。Base64Data を使用する場合は必須です。FullPath を使用する場合、これを空白のままにするとファイル名が自動的に導出されます。 |
| FolderPath | String | False | バッチアップロードされる複数のファイルを含むフォルダへのパス。FolderPath またはFullPath のいずれかを指定し、両方は指定しないでください。 |
| Attachments | String | False | バッチアップロード用の複数の添付ファイルレコードを含む一時テーブル名またはJSON集計を受け入れます。各行にはObjectId とFullPath またはBase64Data などのアップロード詳細が含まれている必要があります。 |
| Content | String | True | FullPath が指定されていない場合に使用される、InputStream としてのファイルコンテンツ。通常はプログラムアップロードに使用されます。 |
Result Set Columns
| Name | Type | Description |
| Id | String | Salesforce で新しくアップロードされた添付ファイルの一意のID。 |
| Success | Boolean | ファイルのアップロードが成功した(true)か失敗した(false)かを示します。 |
| FileIdentifier | String | この結果行のファイルを識別します。FullPath またはFolderPath が使用された場合は完全なファイルパスを含み、Base64Data またはコンテンツストリームが使用された場合はファイル名を含みます。 |
| Errors | String | アップロードが失敗した場合にSalesforce によって返されるエラーメッセージ。エラーコードと説明を含みます。 |