-
Notifications
You must be signed in to change notification settings - Fork 179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TQuickAzure.PutBlob Filesize Issue #32
Comments
It's strange. This function is working for many years in production systems without any issues. |
Have you tried the filename-based version instead? Have you obtained the same size issue? |
I've tested current code with RAD Studio 10.3.3 uploading jpg images without problems. Which delphi version are you using? |
Delphi 10.3.3
Tested with xls = NOK.
…On Wed, 22 Apr 2020 at 14:36, Exilon ***@***.***> wrote:
I've tested current code with RAD Studio 10.3.3 uploading jpg images
without problems. Which delphi version are you using?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#32 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AFAZKEJZWK4Q4WX5O253B7TRN3QGLANCNFSM4MH6KCOA>
.
--
*Limagito.com*
*Automate the Moving of Files*
E-mail: support@limagito.com
Website: limagito.com
Call: +16465830601 (USA number)
Skype User: support@limagito.com
Remote Support: https://limagito.com/remote-support/
|
I'll try the filename-based version asap |
Try stream version with other file types different to xls, like jpg, please. |
Tested with filename-based version: not ok (corrupted xls). Test results:
Pdf: Size on Azure is 112 KiB Xls: Size on Azure is 280 KiB
Pdf: Size on Azure is 108.3 KiB Xls: Size on Azure is 273.96 KiB |
Fixed in next version. Thanks for your report and solution. |
Hi,
When you upload a file to Azure using PutBlob function then the filesize is wrong on Azure. When you download this file again, tested with an excel file, it will be damaged (it will ask for a repair).
The reason is the way the local var Content is handled. I found a fix in the Embarcadero 10.3.3 Demos on GitHub, filename CloudPopulator.pas (Trunk\Object Pascal\Database\CloudAPI\CloudExplorer).
`function TQuickAzure.PutBlob(const azContainer : string; cStream : TStream; const azBlobName : string; out azResponseInfo : TAzureResponseInfo) : Boolean;
var
BlobService : TAzureBlobService;
//Content : TArray;
Content: TBytes;
CloudResponseInfo : TCloudResponseInfo;
container : string;
blobname : string;
begin
azResponseInfo.StatusCode := 500;
if cStream.Size = 0 then
begin
azResponseInfo.StatusMsg := 'Stream is empty';
Exit;
end;
container := CheckContainer(azContainer);
blobname := RemoveFirstSlash(azBlobName);
try
BlobService := TAzureBlobService.Create(fconAzure);
try
BlobService.Timeout := fTimeout;
CloudResponseInfo := TCloudResponseInfo.Create;
try
// Content := StreamToArray(cStream);
Content := ByteContent(cStream);
Result := BlobService.PutBlockBlob(container,blobname,Content,EmptyStr,nil,nil,CloudResponseInfo);
azResponseInfo := GetResponseInfo(CloudResponseInfo);
finally
CloudResponseInfo.Free;
end;
finally
BlobService.Free;
end;
except
on E : Exception do
begin
azResponseInfo.StatusCode := 500;
azResponseInfo.StatusMsg := e.message;
Result := False;
end;
end;
end;`
and added (copied from the Embarcadero Demos on GitHub, CloudPopulator.pas)
`function TQuickAzure.ByteContent(DataStream: TStream): TBytes;
var
Buffer: TBytes;
begin
if not Assigned(DataStream) then
exit(nil);
SetLength(Buffer, DataStream.Size);
// the content may have been read
DataStream.Position := 0;
if DataStream.Size > 0 then
DataStream.Read(Buffer[0], DataStream.Size);
Result := Buffer;
end;`
Regards,
Pascal
The text was updated successfully, but these errors were encountered: