The file storage provider entity containing connection details
The input object containing the file details: - ID: A unique identifier for the file - Name: The filename to use for storage - ProviderID: The ID of the storage provider to use - ContentType: (Optional) The MIME type of the file - ProviderKey: (Optional) Provider-specific key for the file
A promise that resolves to an object containing: - updatedInput: The input object with additional metadata (Status, ContentType, and possibly ProviderKey) - UploadUrl: The pre-authenticated URL for uploading the file
// Create a pre-authenticated upload URL for a PDF document
const fileStorageProvider = await entityMgr.FindById('FileStorageProvider', 'azure-main');
const result = await createUploadUrl(
fileStorageProvider,
{
ID: '123',
Name: 'report.pdf',
ProviderID: fileStorageProvider.ID
}
);
// The content type is automatically determined from the file extension
console.log(result.updatedInput.ContentType); // 'application/pdf'
// The status is set to 'Uploading'
console.log(result.updatedInput.Status); // 'Uploading'
// The upload URL can be sent to the client for direct upload
console.log(result.UploadUrl);
Creates a pre-authenticated upload URL for a file in the specified file storage provider.
This utility function simplifies the process of creating upload URLs by handling common tasks such as:
The function returns both the updated input object (with additional metadata) and the pre-authenticated upload URL that can be used by clients to upload the file directly to the storage provider.