Create a file association object and associate it with an object

post/documents/{objectTypeName}/{objectId}/files
Internal-Use Only

Creates a file association. You can create a file association by using the representation that is contained in the request body or by reusing a file that is already associated with an object. To create a file association using the representation that is contained in the request body, the file to which the file association points (via its Location property) must exist in the Files service and must not be associated with another object. To create a file association by using a file that is already associated with an object, call this endpoint without a request body and use the copyFileFrom parameter to identify the file. The Data Hub service copies the file enabling it to be associated with a different object. The object that is identified by the objectTypeName and objectId in the path is associated with the copied file.

Request Samples

1

Response Samples

1{
2 "creationTimeStamp": "2019-11-06T22:01:23.809Z",
3 "modifiedTimeStamp": "2019-11-06T22:01:23.809Z",
4 "createdBy": "videmo",
5 "modifiedBy": "videmo",
6 "id": "608f37fb-d3b5-4381-bff0-4a6fee1c0e84",
7 "location": "/svi-datahub/documents/files/608f37fb-d3b5-4381-bff0-4a6fee1c0e84/files/608f37fb-d3b5-4381-bff0-4a6fee1c0e84",
8 "properties": {},
9 "contentDisposition": "attachment; filename=\"2cb2668d-218a-2f8a-a5aa-6a9ce54ff739\"",
10 "contentType": "text/plain",
11 "encoding": "UTF-8",
12 "links": [
13 {
14 "method": "GET",
15 "rel": "self",
16 "href": "/files/files/608f37fb-d3b5-4381-bff0-4a6fee1c0e84",
17 "uri": "/files/files/608f37fb-d3b5-4381-bff0-4a6fee1c0e84",
18 "type": "application/vnd.sas.file"
19 },
20 {
21 "method": "GET",
22 "rel": "alternate",
23 "href": "/files/files/608f37fb-d3b5-4381-bff0-4a6fee1c0e84",
24 "uri": "/files/files/608f37fb-d3b5-4381-bff0-4a6fee1c0e84",
25 "type": "application/vnd.sas.summary"
26 },
27 {
28 "method": "PATCH",
29 "rel": "patch",
30 "href": "/files/files/608f37fb-d3b5-4381-bff0-4a6fee1c0e84",
31 "uri": "/files/files/608f37fb-d3b5-4381-bff0-4a6fee1c0e84",
32 "type": "application/vnd.sas.file",
33 "responseType": "application/vnd.sas.file"
34 },
35 {
36 "method": "PUT",
37 "rel": "update",
38 "href": "/files/files/608f37fb-d3b5-4381-bff0-4a6fee1c0e84",
39 "uri": "/files/files/608f37fb-d3b5-4381-bff0-4a6fee1c0e84",
40 "type": "application/vnd.sas.file",
41 "responseType": "application/vnd.sas.file"
42 },
43 {
44 "method": "DELETE",
45 "rel": "delete",
46 "href": "/files/files/608f37fb-d3b5-4381-bff0-4a6fee1c0e84",
47 "uri": "/files/files/608f37fb-d3b5-4381-bff0-4a6fee1c0e84"
48 },
49 {
50 "method": "GET",
51 "rel": "content",
52 "href": "/files/files/608f37fb-d3b5-4381-bff0-4a6fee1c0e84/content",
53 "uri": "/files/files/608f37fb-d3b5-4381-bff0-4a6fee1c0e84/content",
54 "type": "text/plain"
55 },
56 {
57 "method": "PUT",
58 "rel": "updateContent",
59 "href": "/files/files/608f37fb-d3b5-4381-bff0-4a6fee1c0e84/content",
60 "uri": "/files/files/608f37fb-d3b5-4381-bff0-4a6fee1c0e84/content",
61 "type": "*/*",
62 "responseType": "application/vnd.sas.file"
63 },
64 {
65 "method": "POST",
66 "rel": "copyFile",
67 "href": "/files/files/608f37fb-d3b5-4381-bff0-4a6fee1c0e84/copy",
68 "uri": "/files/files/608f37fb-d3b5-4381-bff0-4a6fee1c0e84/copy",
69 "responseType": "application/vnd.sas.file"
70 },
71 {
72 "method": "POST",
73 "rel": "create",
74 "href": "/files/files",
75 "uri": "/files/files",
76 "type": "*/*",
77 "responseType": "application/vnd.sas.file"
78 }
79 ],
80 "name": "2cb2668d-218a-2f8a-a5aa-6a9ce54ff739",
81 "originalName": "My Attachment.txt",
82 "size": 443,
83 "typeDefName": "file",
84 "isLink": false,
85 "version": 3
86}

Path Parameters

NameTypeRequiredDescription
objectId
string
true

The ID of the object.

objectTypeName
string
true

The name of the object type to which the object belongs.

Query Parameters

NameTypeRequiredDescription
copyFileFrom
string
false

The ID of the file to copy. If this parameter is used, do not include a request body.

Request Body

The metadata that associates a file with a document. If the copyFileFrom parameter is used, do not include a request body.

The metadata for a file associated that is with a document. The actual file content is stored by the Files service.

Example:
{"$ref":"#/components/examples/fileExample"}
NameTypeRequiredDescription
links
array [SAS Link]
false

A list of vnd.sas.link objects as per Link representation.

id
string<uuid>
false

A UUID that uniquely identifies this file.

name
string
false

The name of the file.

originalName
string
false

The original name of the file when it was uploaded.

category
string
false

The category to which the file belongs.

location
string
false

A URI for the content of the file.

type
string
false

The MIME type of the file.

size
integer
false

The size (in KB) of the file.

description
string
false

A description of the file.

properties
object
false

The properties to associate with the file.

uploadedAt
string<date-time>
false

The timestamp that indicates when the file was uploaded.

uploadedBy
string
false

The user who uploaded the file.

extractedContent
string
false

Any content that has been extracted for indexing. If the file assocation is an external link, this field can be used to provide extracted content that will be indexed.

isLink
boolean
false

Identifies the location of the content. True is assigned if the file association is a link to an external file. False is assigned if the file has been uploaded to the system as an attachment. This field is read-only. Incoming values are ignored.

Responses

StatusMeaningDescription
201CreatedThe file metadata was created and associated with the object.HeadersSchema
400Bad RequestThe request failed. The file association in the request body was invalid.Schema
404Not FoundThe object does not exist or the user does not have the correct permissions to view the object.Schema