Document Uploading
On the Anduin system, document management is one of the key features, allowing Fund Managers to keep track of subscriptions, investor documents, Fund reference materials, and more. Providing an API for the file system streamlines the connection between your external system and Anduin.
To upload a file to Anduin, you need to follow 3 steps
- Request file upload
- Upload the file to Amazon S3
- Attach the file to Anduin App via API
In the response to the file upload request, you will receive an upload URL generated by Amazon S3, our cloud storage system. You can then use a PUT
request to send the file to S3.
After successfully uploading the file, you can move your files to the Anduin app, such as Attach Signed Subscription Documents, Attach Counter Signed Documents, and more.
Upload file to Amazon S3
In this section, we briefly explain and provide examples of how to upload files directly to Amazon S3. The official Amazon S3 documentation can be found here.
In the response to the file upload API request, you will receive an uploadUrl
field, which is a string formatted as https://***.s3.***.amazonaws.com/api-upload/***
. You need to make a PUT
request to this endpoint, with the binary file as the request body.
Postman approach
One of the easiest ways to test this API is by using Postman . Simply send the request to the uploadUrl
, change the HTTP method to PUT
, and attach the file in binary format in the body.
Programmatically approach
To integrate with your system, you may want to upload the file programmatically. Below, you can find sample scripts in common programming languages.
import fs from "fs";
import fetch from "node-fetch";
async function sendBinaryFile(uploadUrl, filePath) {
try {
const binaryFile = fs.readFileSync(filePath);
const response = await fetch(uploadUrl, {
method: 'PUT',
body: binaryFile
});
if (response.ok) {
console.log('File uploaded successfully');
} else {
console.error('File upload failed:', response.statusText);
}
} catch (error) {
console.error('Error:', error);
}
}
import java.io.IOException;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.file.Files;
import java.nio.file.Path;
public class BinaryFileUploader {
public static void sendBinaryFile(String uploadUrl, String filePath) {
try {
// Read the file into a byte array
byte[] fileBytes = Files.readAllBytes(Path.of(filePath));
// Create an HttpClient
HttpClient client = HttpClient.newHttpClient();
// Build the HTTP PUT request
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(uploadUrl))
.PUT(HttpRequest.BodyPublishers.ofByteArray(fileBytes))
.build();
// Send the request and get the response
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
// Check the response status
if (response.statusCode() == 200) {
System.out.println("File uploaded successfully");
} else {
System.out.println("File upload failed, status code: " + response.statusCode());
}
} catch (IOException | InterruptedException e) {
e.printStackTrace();
}
}
}
import requests
def send_binary_file(uploadUrl, file_path):
try:
# Open the file in binary mode
with open(file_path, 'rb') as file:
# Send the PUT request with the binary file as data
response = requests.put(uploadUrl, data=file)
# Check response status
if response.status_code == 200:
print('File uploaded successfully')
else:
print(f'File upload failed, status code: {response.status_code}')
except Exception as e:
print(f'Error: {e}')
Updated 5 months ago