diff --git a/src/docs/version_001/resources/files/get_file/copy.md b/src/docs/version_001/resources/files/get_file/copy.md index 79e5fe7..ff31d65 100644 --- a/src/docs/version_001/resources/files/get_file/copy.md +++ b/src/docs/version_001/resources/files/get_file/copy.md @@ -1 +1,47 @@ # Get File {% #get-file %} + +This endpoint allows you to retrieve a file that is held in an attachment or image 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 + +--- + +- fileId +- `number` +- The id of the file to be retrieved. + +{% /table %} diff --git a/src/docs/version_001/resources/files/get_file/example.md b/src/docs/version_001/resources/files/get_file/example.md index 903935c..53564a9 100644 --- a/src/docs/version_001/resources/files/get_file/example.md +++ b/src/docs/version_001/resources/files/get_file/example.md @@ -1,4 +1,31 @@ # Retrieve a file from a record in an app -{% code method="GET" heading="/Files/{appId}/{recordId}/{fieldId}" defaultLanguage="bash" } +{% code method="GET" heading="/Files/{appId}/{recordId}/{fieldId}" defaultLanguage="bash" %} + +```bash +curl --location 'https://api.onspring.com/v1/Files/195/1/6989?fileId=89' \ +--header 'X-ApiKey: 000000ffffff000000ffffff/00000000-ffff-0000-ffff-000000000000' +``` + +```csharp +using Onspring.API.SDK.Helpers; + +var httpHelper = new HttpHelper( + config.baseUrl, + config.apiKey +); + +using (var result = httpHelper.GetFileFromRecord(195, 1, 6989, 89)) +{ + Console.WriteLine($"FileName is: {result.FileName}"); + Console.WriteLine($"ContentType: {result.ContentType}"); + Console.WriteLine($"ContentLength: {result.ContentLength}"); + + using (var fileStream = new FileStream($"C:\Users\Public\Documents\{result.FileName}", FileMode.Create)) + { + result.Stream.CopyTo(fileStream); + } +} +``` + {% /code %}