codeunit 50999 ItemPictureBulkExtract
{
trigger OnRun()
var
PicInStream: InStream;
Index: Integer;
TenantMedia: Record "Tenant Media";
FileName: Text;
datacompresion: Codeunit "Data Compression";
ZipFileName: Text;
ZipOutStream: OutStream;
ZipInStream: InStream;
blobStorage: Codeunit "Temp Blob";
begin
datacompresion.CreateZipArchive();
repeat
with item do begin
if Picture.Count > 0 then begin
for Index := 1 to Picture.Count do begin
if TenantMedia.Get(Picture.Item(Index)) then begin
TenantMedia.calcfields(Content);
if TenantMedia.Content.HasValue then begin
FileName := "No." + '-' + format(Index) + GetTenantMediaFileExtension(TenantMedia);
TenantMedia.Content.CreateInStream(PicInstream);
datacompresion.AddEntry(PicInStream, FileName);
end;
end;
end;
end;
end;
until Item.Next() = 0;
blobStorage.CreateOutStream(ZipOutStream);
datacompresion.SaveZipArchive(ZipOutStream);
datacompresion.CloseZipArchive();
blobStorage.CreateInStream(ZipInStream);
DownloadFromStream(ZipInStream, '', '', '', FileName)
end;