Hi! 👋
Firstly, thanks for your work on this project! 🙂
Today I used patch-package to patch @tus/azure-store@2.0.0 for the project I'm working on.
Steps to reproduce:
- Uploading a file to azure blob store.
- Navigate to uploaded file url provided by the Tus Server.
- Request fails with 500 error and message "Metadata string is not valid".
Here is the diff that solved my problem:
diff --git a/node_modules/@tus/azure-store/dist/index.js b/node_modules/@tus/azure-store/dist/index.js
index 77efab1..1ad25c9 100644
--- a/node_modules/@tus/azure-store/dist/index.js
+++ b/node_modules/@tus/azure-store/dist/index.js
@@ -71,7 +71,7 @@ export class AzureStore extends DataStore {
const upload = JSON.parse(propertyData.metadata.upload);
// Metadata is base64 encoded to avoid errors for non-ASCII characters
// so we need to decode it separately
- upload.metadata = Metadata.parse(JSON.stringify(upload.metadata ?? {}));
+ let metadataStr
+ if (typeof upload.metadata === 'string') {
+ metadataStr = upload.metadata
+ } else if (upload.metadata && typeof upload.metadata === 'object') {
+ metadataStr = JSON.stringify(upload.metadata??{})
+ } else {
+ metadataStr = '{}'
+ }
+ upload.metadata = Metadata.parse(metadataStr)
await this.cache.set(appendBlobClient.url, upload);
log('metadata returned from blob get properties');
return upload;
This issue body was partially generated by patch-package.
Hi! 👋
Firstly, thanks for your work on this project! 🙂
Today I used patch-package to patch
@tus/azure-store@2.0.0for the project I'm working on.Steps to reproduce:
Here is the diff that solved my problem:
This issue body was partially generated by patch-package.