我正在尝试使用 Dynamics Business Central 在 azure 存储上创建一个文件,然后尝试将一个字符串写入该文件。我无法创建文件 任何人都可以在这方面帮助我。
我的示例代码是
cha := 13;
msVersion := '02-14-2014';
MethodType := 'CreateFile';
keyss := 'i0PNZ6Ykse7oSSfUzFeA36rQf5wybQWh5Jol0NRM4sal4s8B3ipkjvfzcsP8';
//contenttype := 'This is sample text.';
//contentLength := StrLen(contenttype);
dateInRfc1123Format := CurrentDateTime;
//canonicalizedHeaders := 'x-ms-date:' + FORMat(dateInRfc1123Format) + Format(cha) + 'x-ms-version:02-02-2019';
requestMethod := 'PUT';
urlPath := 'lables/' + 'tre11.csv';
canonicalizedResource := '/bcstorage/labes/tre11.csv';
canonicalizedHeaders := 'x-ms-content-length:1024' + Format(cha) + 'x-ms-date:' + FORMat(dateInRfc1123Format) + Format(cha) + 'x-ms-type:file' + Format(cha) + 'x-ms-version:' + msVersion;
stringToSign := (requestMethod + Format(cha) + Format(cha) + Format(cha) + Format(cha) + Format(cha) + Format(cha) + Format(cha) + Format(cha) +
Format(cha) + Format(cha) + Format(cha) + Format(cha) + canonicalizedHeaders + canonicalizedResource);
authorizationHeader := 'SharedKey bc365storage:' + EncryptionManagement.GenerateBase64KeyedHashAsBase64String(stringToSign, keyss, 2);
Message((authorizationHeader));
request.SetRequestUri('https://bcstorage.file.core.windows.net/labes/tre11.csv');
//request.GetHeaders(RequestHeader);
request.Method := requestMethod;
RequestHeader.Add('x-ms-date', FORMat(dateInRfc1123Format));
RequestHeader.Add('x-ms-version', msVersion);
RequestHeader.Add('Authorization', authorizationHeader);
RequestHeader.Add('Accept-Charset', 'UTF-8');
//RequestHeader.Add('Content-Type', 'text/xml;charset=utf-8');
if MethodType = 'CreateFile' then begin
RequestHeader.Add('x-ms-content-length', '1024');
RequestHeader.Add('x-ms-type', 'file');
end;
client.Get('https://bcstorage.file.core.windows.net/labes/tre11.csv', hhtpres);
hhtpres.Content.ReadAs(res);
Message(res);
test := client.Send(request, hhtpres);
但是我得到了错误的响应,我也无法创建文件。