-
Notifications
You must be signed in to change notification settings - Fork 3
/
file_operations.yaml
364 lines (345 loc) · 11.7 KB
/
file_operations.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
openapi: 3.0.0
info:
title: File Operations
description: >-
The official SeaTable API Reference (OpenAPI 3.0).
version: "5.1"
servers:
- url: "https://{server}"
variables:
server:
default: cloud.seatable.io
x-readme:
explorer-enabled: true
metrics-enabled: false
proxy-enabled: false
components:
# Security scheme definitions (see Authentication)
securitySchemes:
ApiTokenAuth:
type: http
scheme: bearer
description: This is the [API-Token](/reference/authentication).
# Reusable path, query, header and cookie parameters
parameters:
file_path:
name: path
in: query
schema:
type: string
pattern: ^\/(images|files){1}\/[0-9]{4}\-[0-9]{2}\/.
description: "Path to the file"
example: "/images/2021-03/test.png"
required: true
upload_link:
name: upload_link
description: "This is the value you got from the call Get File/Image Upload Link via API Token."
in: path
schema:
type: string
pattern: ^[a-z0-9]{8}(-[a-z0-9]{4}){3}-[a-z0-9]{12}$
required: true
example: "5e666848-4152-45e5-990e-d686960f2a05"
custom_folder_path:
name: path
in: query
schema:
type: string
description: "Path of the custom folder"
example: "/"
required: true
custom_folder_file_name:
name: name
in: query
schema:
type: string
description: "Name of the file in the custom folder"
example: "b374.pdf"
required: true
custom_folder_path_with_filename:
name: path
in: query
schema:
type: string
description: "Path and name of the file in the custom folder"
example: "/supplierOne/b374.pdf"
required: true
# Reusable schemas (data models)
schemas:
upload_file_image:
type: object
properties:
file:
type: string
description: >-
The file or image you'd like to upload from your local
drive.
format: binary
parent_dir:
type: string
description: >-
This is the value of the `parent_path` you got from the call
**Get File/Image Upload Link via API Token**.
example: /asset/a275d870-fd55-48e4-8c4a-5fd6f2549765
replace:
type: string
enum: ["0", "1"]
description: >-
Do you want to overwrite a file/image with the same name?
`0` - No, `1` - Yes. Optional. `0` by default. If existing
file is not overwritten, the uploaded file will be renamed
as `filename(1).xxx`.
example: "0"
relative_path:
type: string
description: >-
If you are uploading a file, use the value of the
`file_relative_path` returned in the call **Get File/Image
Upload Link via API Token**; or the `img_relative_path` for
image.
example: images/2021-08
pattern: '^(images|files){1}\/[0-9]{4}\-[0-9]{2}$'
required:
- file
- parent_dir
- relative_path
paths:
# Files & Images
/api/v2.1/dtable/app-upload-link/:
get:
tags:
- Files & Images
summary: Get Upload Link
operationId: getUploadLink
description: |
With the **API token** (not the Base Token), you can generate an upload link, the parent- and the relative path. These information are needed to upload a file / an image to a bases.
Then this file/image can be attached to a file/image column.
> 📘 The upload link is only valid for a short time
>
> The upload link is only valid for some minutes. After that the upload link must be created again.
security:
- ApiTokenAuth: []
responses:
"200":
description: OK
content:
application/json:
schema:
type: object
example:
upload_link: >-
https://cloud.seafile.com/seafhttp/upload-api/83e701c8-84ba-498c-91b1-ddb3789edb7e
parent_path: /asset/a275d870-fd55-48e4-8c4a-5fd6f2549765
img_relative_path: images/2021-08
file_relative_path: files/2021-08
/seafhttp/upload-api/{upload_link}?ret-json=1:
post:
tags:
- Files & Images
summary: Upload File (or Image)
operationId: uploadFile
description: |
Upload a file or an image as an attachment to a base. To execute this request you need to generate an upload link first.
> 📘 Three steps to add a file/an image to a base
>
> To add an image or a file to a base, three steps are necessary:
> 1. [Generate an upload link](/reference/getuploadlink).
> 2. Upload the file to the base as an attachment. (this article)
> 3. [Update a row](/reference/updaterow) and attach the file/the image to a file or image column.
> 📘 Different variable names
>
> Pay attention that the return values of upload link have slightly different names, so `parent_path` is `parent_dir` in this call.
## Attach the file/image to a file or image column
After uploading the file/image to a base, SeaTable saves the uploaded file at non-public URL in the form: `/workspace/{workspace_id}`+`parent_dir`+`relative_path`+`name`.
Here is an example how this might look like: `https://cloud.seatable.io/workspace/24/asset/55f2f056-5da1-4095-b5f8-791bb51b991e/images/2023-07/party.png`
If you are logged in with your browser, you can access this file. Otherwise you will see the login screen.
Knowing this URL, you can add a new row or update an existing row and use the URL to add this attachment to your file/image column.
```
# Example how to add an already uploaded image to a row:
"row": {
"My Image Column": ["/workspace/24/asset/55f2f056-5da1-4095-b5f8-791bb51b991e/images/2023-07/party.png`"]
}
# Example how to add an already uploaded file to a row:
"row": {
"File Column": [{
"name": "invoice.pdf",
"size": 101454,
"type": "file",
"url": "/workspace/24/asset/55f2f056-5da1-4095-b5f8-791bb51b991e/images/2023-07/invoice.pdf"
}]
}
```
> 🚧 File requires the input variables size, type and url
>
> As you can see, in the case of an image the URL is sufficient to attach the image to an image column. In case of a file, you have to provide all four input values.
requestBody:
content:
multipart/form-data:
schema:
$ref: "#/components/schemas/upload_file_image"
security:
- ApiTokenAuth: []
parameters:
- $ref: "#/components/parameters/upload_link"
responses:
"200":
description: OK
content:
application/json:
schema:
type: array
items:
type: object
example:
- name: favicon.ico
id: b4356e3000d01a37b458524b59cecb1a5d23d964
size: 67646
/api/v2.1/dtable/app-download-link/:
get:
tags:
- Files & Images
summary: Get File Download Link
operationId: getFileDownloadLink
description: |
Get the file download link of a base's attachment.
security:
- ApiTokenAuth: []
parameters:
- $ref: "#/components/parameters/file_path"
responses:
"200":
description: OK
content:
application/json:
schema:
type: object
example:
download_link: >-
https://cloud.seatable.io/seafhttp/files/12345678-1234-4672-834c-4eca40dc104b/test.png
/api/v2.1/dtable/app-asset/:
delete:
tags:
- Files & Images
summary: Delete a Base Asset
operationId: DeleteBaseAsset
description: |
Delete a base's attachment.
security:
- ApiTokenAuth: []
parameters:
- $ref: "#/components/parameters/file_path"
responses:
"200":
description: OK
content:
application/json:
schema:
type: object
example:
success: true
# Files & Images (Custom Folder)
/api/v2.1/dtable/custom/app-asset-dir/:
get:
tags: [Files & Images (Custom Folder)]
summary: Get Files from Folder
operationId: getCustomFiles
security:
- ApiTokenAuth: []
parameters:
- $ref: "#/components/parameters/custom_folder_path"
responses:
"200":
description: OK
content:
application/json:
schema:
type: object
example:
dir:
- name: "Invoices"
- name: "Requests"
file:
- name: "b347.pdf"
/api/v2.1/dtable/custom/app-asset-file/:
get:
tags: [Files & Images (Custom Folder)]
summary: Get File Metadata
operationId: getCustomFileMetadata
security:
- ApiTokenAuth: []
parameters:
- $ref: "#/components/parameters/custom_folder_path"
- $ref: "#/components/parameters/custom_folder_file_name"
responses:
"200":
description: OK
content:
application/json:
schema:
type: object
example:
dirent:
is_file: true
obj_name: "b347.pdf"
file_size: 11583
last_update: "2023-04-11T14:59:53+08:00"
uuid: "2bbe9499-e1df-4086-bdd3-d130d6c91bd3"
delete:
tags: [Files & Images (Custom Folder)]
summary: Delete a Base Asset in Custom Folder
operationId: DeleteBaseCustomFolderAsset
description: |
Delete a base's attachment in custom folder.
security:
- ApiTokenAuth: []
parameters:
- $ref: "#/components/parameters/custom_folder_path_with_filename"
responses:
"200":
description: OK
content:
application/json:
schema:
type: object
example:
success: true
/api/v2.1/dtable/custom/app-upload-link/:
get:
tags: [Files & Images (Custom Folder)]
summary: Get Upload Link
operationId: getCustomUploadLink
security:
- ApiTokenAuth: []
parameters:
- $ref: "#/components/parameters/custom_folder_path"
responses:
"200":
description: OK
content:
application/json:
schema:
type: object
example:
dirent:
upload_link: "https://cloud.seatable.io/seafhttp/upload-api/e943a56a-c5b3-441a-ac1d-9199819dec71"
parent_path: "/asset/1338f224-8482-4d71-b8be-63c8f37b896a/custom"
relative_path": "/"
/api/v2.1/dtable/custom/app-download-link:
get:
tags: [Files & Images (Custom Folder)]
summary: Get Download Link
operationId: getCustomDownloadLink
security:
- ApiTokenAuth: []
parameters:
- $ref: "#/components/parameters/custom_folder_path_with_filename"
responses:
"200":
description: OK
content:
application/json:
schema:
type: object
example:
dirent:
download_link: "https://cloud.seatable.io/seafhttp/files/a73e26e9-0417-4d98-bb5d-92826f4af671/b347.pdf"