Last update:
July 29, 2024
Getting Started
To start uploading files from clients applications:
- Register the upload scope
- Query settings.
- Upload files.
- Extend xAPI.
- Implement security.
- Download files.
- Delete files.
Register Upload Scope¶
Update appsettings.json with file upload scope settings:
appsettings.json
{
"FileUpload": {
"RootPath": "attachments",
"Scopes": [
{
"Scope": "quote-attachments",
"MaxFileSize": 123,
"AllowedExtensions": [ ".jpg", ".pdf", ".png", ".txt" ]
"AllowAnonymousUpload": true
}
]
}
}
Query Settings¶
Use GraphQL to query file upload options for the desired scope from client application:
query {
fileUploadOptions(scope: "quote-attachments"){
scope
maxFileSize
allowedExtensions
allowAnonymousUpload
}
}
Upload files¶
Use the provided API endpoint to upload files as multipart/form-data and obtain a safe file ID:
Extend xAPI¶
Extend your XAPI queries and mutations to include file attachments with the safe file ID as needed for your application:
mutation {
addQuoteAttachments(
command: {
quoteId: "a73c6031-ab6a-4acc-9f16-466d287d7565"
urls: [
"/api/files/699fa784949a40c1acd891f74b4223d9"
"/api/files/4c25e506a637407782bda5a5480f26a2"
]
}
)
}
Implement Security¶
Implement security callback to control access to files based on your application's requirements with impementation of IFileAuthorizationRequirementFactory
Download Files¶
Use the provided API endpoint to download files using the safe file ID obtained during upload:
Delete Files¶
Use deleteFile mutation to remove file from storage: