Table of Contents

Search

  1. Preface
  2. Introduction to Business Entity Services
  3. Enterprise Java Bean Business Entity Service Calls
  4. Representational State Transfer Business Entity Service Calls
  5. Simple Object Access Protocol Business Entity Service Calls
  6. Services for Cross-reference Records and BVT Calculations
  7. Supporting Corporate Linkage Service
  8. External Calls to Cleanse, Analyze, and Transform Data
  9. Using REST APIs to Add Records
  10. Using REST APIs to Upload Files

Attaching Files to Records

Attaching Files to Records

Before you attach a file to a record, create the metadata of the file and then upload the file to the temporary storage.
  1. To create the metadata of a file, use the Create File Metadata REST API with TEMP as the storage type.
    For example, the following request creates the metadata for the
    Document_3.pdf
    file:
    POST http://localhost:8080/cmx/file/localhost-orcl-MDM_SAMPLE/TEMP Content-Type: application/json { "fileName": "Document_3.pdf", "fileType": "pdf", "fileContentType": "application/pdf" }
    Always create the file metadata in the TEMP storage.
    The Create File Metadata REST API returns an ID for the file. The file ID is in the following format:
    <Storage Type>_<RowID>
    . Where the RowID refers to the row ID of the file that you upload to the storage.
    In the example, the API call returns the following ID for the
    Document_3.pdf
    file:
    TEMP_SVR1.OJU3
    You can use the file ID to upload, attach, update, download, and delete the file.
  2. To upload the file, use the Upload File Content REST API with TEMP as the storage type.
    For example, the following request uploads the file to the TEMP storage:
    PUT http://localhost:8080/cmx/file/localhost-orcl-MDM_SAMPLE/TEMP/TEMP_SVR1.OJU3/content Content-Type: application/octet-stream <file object (upload using REST client)>
    After you upload a file, the TEMP storage stores the file for a pre-configured period of 60 minutes. You must attach the file to a record before the pre-configured period expires.
  3. To create a record and attach the file to a new record, use the Create Record REST API.
    For example, the following request creates a record and attaches the file with the file ID,
    TEMP_SVR1.OJU3
    :
    POST http://localhost:8080/cmx/cs/localhost-orcl-MDM_SAMPLE/Person?systemName=Admin Content-Type: application/json { "frstNm":"John", "lstNm":"Smith", "addrLn1":"2100 Breverly Road", "addrTyp":{ "addrTyp":"Billing", "addrTypDesc":"Billing" }, "cntryCd":{ "cntryCd":"AX", "cntryDesc":"Aland" }, "attachments":{ "item":[ { "fileId":"TEMP_SVR1.OJU3" } ] } }
    When you attach a file to a record, the process stores the file to the database. The ID of the file changes to
    DB_<RowID>
    , where DB indicates that the file is stored in the database.
  4. To replace a file attached to a record, use the Upload File Content REST API with DB as the storage type.
    For example, the following request replaces the attached file with the file ID,
    DB_SVR1.OJU3
    , in the database:
    PUT http://localhost:8080/cmx/file/localhost-orcl-MDM_SAMPLE/DB/DB_SVR1.OJU3/content Content-Type: application/octet-stream <file object (upload using REST client)>
    The storage type in the request URL is DB.
  5. To edit the file metadata after you attach a file to a record, use the Update File Metadata REST API with DB as the storage type.
    For example, the following request updates the file metadata of a file associated with the file ID,
    DB_SVR1.OJU3
    , in the DB storage:
    PUT http://localhost:8080/cmx/file/localhost-orcl-MDM_SAMPLE/DB/DB_SVR1.OJU3 Content-Type: application/json { "fileName": "Document_4.pdf", "fileType": "pdf", "fileContentType": "application/pdf" }
  6. To download a file attached to a record, use the GET File Content REST API with DB as the storage type.
    For example, the following request downloads a file associated with the file ID,
    DB_SVR1.OJU3
    , from the DB storage:
    GET http://localhost:8080/cmx/file/localhost-orcl-MDM_SAMPLE/DB/DB_SVR1.OJU3/content
  7. To delete a file attached to a record, use the Delete File REST API with DB as the storage type.
    For example, the following request deletes a file associated with the file ID,
    DB_SVR1.OJU3
    , from the DB storage:
    DELETE http://localhost:8080/cmx/file/localhost-orcl-MDM_SAMPLE/DB/DB_SVR1.OJU3

0 COMMENTS

We’d like to hear from you!