docs: add add file section to version 1
This commit is contained in:
@@ -1 +1,98 @@
|
||||
# Add File {% #add-file %}
|
||||
|
||||
This endpoint allows you to add a file to an image or attachment field on a record in an app.
|
||||
|
||||
## Path Parameters
|
||||
|
||||
{% table %}
|
||||
|
||||
- Parameter Name
|
||||
- Data Type
|
||||
- Description
|
||||
|
||||
---
|
||||
|
||||
- appId
|
||||
- `number`
|
||||
- The id of the app or survey where the file is held.
|
||||
|
||||
---
|
||||
|
||||
- recordId
|
||||
- `number`
|
||||
- The id of the record where the file is held.
|
||||
|
||||
---
|
||||
|
||||
- fieldId
|
||||
- `number`
|
||||
- The id of the field where the file is held.
|
||||
|
||||
{% /table %}
|
||||
|
||||
## Query Parameters
|
||||
|
||||
{% table %}
|
||||
|
||||
- Parameter Name
|
||||
- Data Type
|
||||
- Description
|
||||
|
||||
---
|
||||
|
||||
- fileName
|
||||
- `string`
|
||||
- The name of the file being added.
|
||||
|
||||
---
|
||||
|
||||
- modifiedTime
|
||||
- `string`
|
||||
- The modified date and time to be stored with the file. The value should be in this format: `yyyy-mm-dd hh:mm:ssZ`.
|
||||
|
||||
---
|
||||
|
||||
- fileNotes
|
||||
- `string`
|
||||
- The notes to be stored with the file.
|
||||
|
||||
{% /table %}
|
||||
|
||||
## Request Headers
|
||||
|
||||
{% table %}
|
||||
|
||||
- Header
|
||||
- Description
|
||||
|
||||
---
|
||||
|
||||
- Content-Type
|
||||
- The content type for the file being added.
|
||||
|
||||
---
|
||||
|
||||
- Content-Length
|
||||
- The number of bytes in the file.
|
||||
|
||||
{% table %}
|
||||
|
||||
## Request Body
|
||||
|
||||
The body of the request should include only the bytes that represent the files content.
|
||||
|
||||
## Response Body Properties
|
||||
|
||||
{% table %}
|
||||
|
||||
- Property Name
|
||||
- Data Type
|
||||
- Description
|
||||
|
||||
---
|
||||
|
||||
- fileId
|
||||
- `number`
|
||||
- The id of the created file.
|
||||
|
||||
{% /table %}
|
||||
|
||||
@@ -1,5 +1,43 @@
|
||||
# Add a file to a record in an app
|
||||
|
||||
{% code method="POST" heading="files/{appId}/{recordId}/
|
||||
{fieldId}" defaultLanguage="bash" }
|
||||
{% code method="POST" heading="files/{appId}/{recordId}/{fieldId}" defaultLanguage="bash" }
|
||||
|
||||
```bash
|
||||
|
||||
curl --location 'https://api.onspring.com/v1/files/362/196/10365?fileName=test-attachment.txt&modifiedTime=2022-10-14%2000%3A00%3A00Z&fileNotes=These%20are%20some%20notes' \
|
||||
--header 'Content-Type: text/plain' \
|
||||
--header 'Content-Length: 20' \
|
||||
--data '@test-attachment.txt'
|
||||
```
|
||||
|
||||
```csharp
|
||||
// Option 1: File you want to add physically exists on disk
|
||||
var filePath = "C:\Users\Public\Documents\Contract.pdf";
|
||||
var contentType = "application/pdf";
|
||||
var fileNotes = "Initial revision";
|
||||
var result = httpHelper.AddFileToRecord(362, 196, 10365, filePath, contentType, fileNotes);
|
||||
Console.WriteLine($"New File Id is: {result.CreatedId}");
|
||||
|
||||
// Option 2: Use file stream
|
||||
var fileName = "Contract.pdf";
|
||||
var contentType = "application/pdf";
|
||||
var modifiedTime = DateTime.UtcNow;
|
||||
var fileNotes = "Initial revision";
|
||||
using (Stream stream = new MemoryStream())
|
||||
{
|
||||
AddEditResult result = httpHelper.AddFileToRecord(362, 196, 10365, stream, fileName, contentType, modifiedTime, fileNotes);
|
||||
Console.WriteLine($"New File Id is: {result.CreatedId}");
|
||||
}
|
||||
```
|
||||
|
||||
{% /code %}
|
||||
|
||||
{% code heading="RESPONSE" defaultLanguage="json" %}
|
||||
|
||||
```json
|
||||
{
|
||||
"fileId": 7346
|
||||
}
|
||||
```
|
||||
|
||||
{% /code %}
|
||||
|
||||
Reference in New Issue
Block a user