File Management Service¶
The File Management Service allows files to be uploaded and thereafter managed by Issuers.
Restricted Experimental Service
This service exists as an experiment to enable rapid prototyping of certain use-cases, such as linking to files / binary data within Credentials.
Ecosystems must be on a paid plan in order to make use of this service.
Data Security Precautions
Any file uploaded through this service is accessible over the internet to anyone who has the URL.
Although the URLs are extremely long and securely generated (thus are extremely costly to brute force), we do not recommend storing highly-sensitive files or documents via the File Management Service.
For example, government-issued IDs, social security cards, birth certificates, passports, etc. should not be uploaded to this service.
Upload File¶
Uploads a file to Trinsic's CDN.
contents must be the raw contents of the file, with a current maximum of 4 megabytes (4,194,304 bytes).
mime_type must be the MIME Type of the file you are uploading. This determines the file's resulting extension, as well as how it is treated when opened by a browser (displayed as an image, downloaded directly, etc.).
If you do not know the MIME Type of the file being uploaded, or otherwise cannot provide it, use application/octet-stream as a safe default.
The url returned by this endpoint will contain a Hashlink query parameter, in the form of ?hl={hash}. The value of hash is a Multihash string, encoding the hash of the uploaded file contents.
The hl parameter is expected to be included with the URL whenever it is issued in a credential. This allows the cryptographic signature to cover the contents of the file (through its hash), without having to include the entire raw file contents in the credential itself.
// Get raw bytes of string
const fileBytes = new TextEncoder().encode("Hello, world!");
const fileMimeType = "application/text";
const uploadResponse = await trinsic.fileManagement().uploadFile(
UploadFileRequest.fromPartial({
contents: fileBytes,
mimeType: fileMimeType,
}),
);
// Get raw bytes of string
var fileBytes = Encoding.UTF8.GetBytes("Hello, world!");
const string fileMimeType = "application/text";
var uploadResponse = trinsic.FileManagement.UploadFile(new UploadFileRequest {
Contents = ByteString.CopyFrom(fileBytes),
MimeType = fileMimeType
});
# Get raw bytes of string
file_bytes = bytes("Hello, world!", "utf-8")
file_mime_type = "application/text"
upload_response = await trinsic.file_management.upload_file(
request=UploadFileRequest(file_bytes, file_mime_type)
)
uploadResponse, err := trinsic.FileManagement().UploadFile(context.Background(),
&filemanagement.UploadFileRequest{
Contents: []byte("Hello, world!"),
MimeType: "application/text",
})
// Get raw bytes of string
byte[] fileBytes = "Hello, world!".getBytes(StandardCharsets.UTF_8);
String fileMimeType = "application/text";
var uploadResponse =
trinsic
.fileManagement()
.uploadFile(
UploadFileRequest.newBuilder()
.setContents(ByteString.copyFrom(fileBytes))
.setMimeType(fileMimeType)
.build())
.get();
UploadFileRequestGet File¶
Fetches information about a file via its ID.
Only files uploaded by the calling account will be returned.
const getFileResponse = await trinsic.fileManagement().getFile(
GetFileRequest.fromPartial({
id: fileId,
}),
);
var getFileResponse = trinsic.FileManagement.GetFile(new GetFileRequest {
Id = fileId
});
get_response = await trinsic.file_management.get_file(
request=GetFileRequest(file_id)
)
getFileResponse, err := trinsic.FileManagement().GetFile(context.Background(),
&filemanagement.GetFileRequest{
Id: fileId,
})
var getFileResponse =
trinsic.fileManagement().getFile(GetFileRequest.newBuilder().setId(fileId).build()).get();
Delete File¶
Deletes a file from Trinsic's CDN.
Only files uploaded by the calling account may be deleted.
await trinsic.fileManagement().deleteFile(
DeleteFileRequest.fromPartial({
id: fileId,
}),
);
trinsic.FileManagement.DeleteFile(new DeleteFileRequest {
Id = fileId
});
await trinsic.file_management.delete_file(request=DeleteFileRequest(file_id))
deleteResponse, err := trinsic.FileManagement().DeleteFile(context.Background(),
&filemanagement.DeleteFileRequest{
Id: fileId,
})
trinsic.fileManagement().deleteFile(DeleteFileRequest.newBuilder().setId(fileId).build()).get();
DeleteFileRequest. Empty payload.List Files¶
Queries the files uploaded by the calling account.
const listFilesResponse = await trinsic.fileManagement().listFiles(
ListFilesRequest.fromPartial({
query: "SELECT * FROM _ ORDER BY _.uploadDate DESC OFFSET 0 LIMIT 100",
}),
);
var listFilesResponse = trinsic.FileManagement.ListFiles(new ListFilesRequest {
Query = "SELECT * FROM _ ORDER BY _.uploadDate DESC OFFSET 0 LIMIT 100"
});
list_response = await trinsic.file_management.list_files(
request=ListFilesRequest(
query="SELECT * FROM _ ORDER BY _.uploadDate DESC OFFSET 0 LIMIT 100"
)
)
listFilesResponse, err := trinsic.FileManagement().ListFiles(context.Background(),
&filemanagement.ListFilesRequest{
Query: "SELECT * FROM _ ORDER BY _.uploadDate DESC OFFSET 0 LIMIT 100",
})
var listFilesResponse =
trinsic
.fileManagement()
.listFiles(
ListFilesRequest.newBuilder()
.setQuery("SELECT * FROM _ ORDER BY _.uploadDate DESC OFFSET 0 LIMIT 100")
.build())
.get();
ListFilesRequest if more data is available for queryListFilesRequestcontinuation_tokenListFilesRequestGet Storage Statistics¶
Returns aggregate statistics regarding the files uploaded by the calling account.
const getStorageStatsResponse = await trinsic
.fileManagement()
.getStorageStats();
var getStorageStatsResponse = trinsic.FileManagement.GetStorageStats();
get_stats_response = await trinsic.file_management.get_storage_stats()
getStatsResponse, err := trinsic.FileManagement().GetStorageStats(context.Background())
var getStatsResponse = trinsic.fileManagement().getStorageStats().get();
GetStorageStatsRequest