So I'm attempting to create a SAS url that I can do a PUT on. New and updated, this is what I do server side:
async getFileUploadUrl(path) {
const now = new Date().toUTCString();
const startsOn = new Date(now);
startsOn.setMinutes(startsOn.getMinutes() - 10); // Skip clock skew with server
const expiresOn = new Date(now);
expiresOn.setHours(expiresOn.getHours() + 1); // Expires in one hour
const encodedURI = encodeURI(path);
const sas = generateDataLakeSASQueryParameters({
fileSystemName: this.fileSystemClient.name, // Created from my container I want to work in.
fileName: path, // Filename including its path
permissions: DataLakeSASPermissions.parse("c"), // c as in Create
startsOn,
expiresOn,
ipRange: { start: "0.0.0.0", end: "255.255.255.255" }, // All for dev purposes
protocol: SASProtocol.HttpsAndHttp, // Both for now (dev purposes)
},
new StorageSharedKeyCredential(this.storageAccountName, this.accountKey)
);
const sasUrl = `${this.fileSystemClient.url}/${encodedURI}?${sas.toString()}`;
return {
sasUrl,
};
}
And then client side:
const { sasUrl } = response;
const request = new XMLHttpRequest();
request.open('PUT', sasUrl);
request.setRequestHeader("x-ms-date", new Date().toUTCString());
request.setRequestHeader("x-ms-blob-type", 'BlockBlob');
request.send(file)
All I get in response is 400: An HTTP header that's mandatory for this request is not specified.