Что нового
  • Что бы вступить в ряды "Принятый кодер" Вам нужно:
    Написать 10 полезных сообщений или тем и Получить 10 симпатий.
    Для того кто не хочет терять время,может пожертвовать средства для поддержки сервеса, и вступить в ряды VIP на месяц, дополнительная информация в лс.

  • Пользаватели которые будут спамить, уходят в бан без предупреждения. Спам сообщения определяется администрацией и модератором.

  • Гость, Что бы Вы хотели увидеть на нашем Форуме? Изложить свои идеи и пожелания по улучшению форума Вы можете поделиться с нами здесь. ----> Перейдите сюда
  • Все пользователи не прошедшие проверку электронной почты будут заблокированы. Все вопросы с разблокировкой обращайтесь по адресу электронной почте : info@guardianelinks.com . Не пришло сообщение о проверке или о сбросе также сообщите нам.

Free component to handle ZIP files in a TMS WEB Core application

Sascha

Заместитель Администратора
Команда форума
Администратор
Регистрация
9 Май 2015
Сообщения
1,072
Баллы
155
Возраст
52


Yesterday we introduced

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

as a free component to be used with

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

. If you would like to work with ZIP files in a web application then we have good news for you! We created another free component: TWebZip.

TWebZip is a wrapper around the open source

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

library. JSZip makes it possible to create, read, modify and download ZIP files directly in a client application. For limitations of the library please check the

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

.

Features of TWebZip

The supported data types are: string, base64 encoded string (via a parameter setting), TJSArrayBuffer and TBytes.

Drop the non-visual TWebZip component onto the form and you have an empty ZIP file already! You can also open a ZIP file, for example through a TWebFilePicker:
procedure TForm1.WebFilePicker1Change(Sender: TObject);
begin
if WebFilePicker1.Files.Count > 0 then
WebFilePicker1.Files[0].GetAsArrayBuffer;
end;

procedure TForm1.WebFilePicker1GetFileAsArrayBuffer(Sender: TObject; AFileIndex: Integer; ABuffer: TJSArrayBufferRecord);
begin
WebZip1.Open(ABuffer);
end;

procedure TForm1.WebZip1ZipLoaded(Sender: TObject);
begin
//This is the implementation of the OnZipLoaded event:
//here we know that the ZIP was successfully opened
//and we can proceed with related calculations/tasks
end;
To add files to the ZIP, use the Add method. The first parameter is the filename with extension and the second parameter is the data to be added to the file. Keep in mind that if your ZIP already contains a file with a given name then it will override the content.
WebZip1.Add('subfolder/sub.txt', 'I''m in a subfolder!'); //Add sub.txt in the 'subfolder' folder
WebZip1.Add('hello.txt', 'Hello World'); //Adds hello.txt to the ZIP and sets the content to 'Hello World'
WebZip1.Add('hello.txt', 'Hello ZIP'); //Overrides the content of hello.txt
To read the content of a file, use the ReadAsString, ReadAsArrayBuffer or ReadAsBytes method based on which data type you need for further processing. These methods are asynchronous. The first parameter is the filename you want to read and the second is the anonymous method for processing the data.
WebZip1.ReadAsString('hello.txt', procedure(AFileName, AData: string)
begin
//process AData here
end);
To remove files, use the Remove(FileName) or RemoveAll methods.
WebZip1.Remove('hello.txt'); //removes hello.txt from ZIP
WebZip1.RemoveAll; //removes all of the files from the ZIP
Download the ZIP you created or modified with different compression levels. More information on these levels can be found

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

.
WebZip1.Download('myzip.zip', zcStore); //no compression
WebZip1.Download('myzip.zip', zcDeflateLevel1); //best speed
WebZip1.Download('myzip.zip', zcDeflateLevel9); //best compression
Follow your download progress by implementing the OnProgress event:
procedure TForm1.WebZip1Progress(Sender: TObject; APercent: Single; ACurrentFile: string);
begin
WebProgressBar1.Position := Round(APercent);
end;
There are also extra properties for: file count (TWebZip.FileCount), file names (TWebZip.FileName, TWebZip.FileNames) and file comments (TWebZip.FileComment).

If you would like to see how TWebZip works in practice, then head over to our

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

where you can upload images (JPEG or ZIP containing JPEGs) and download their grayscale version in a ZIP file. As we mentioned at the beginning of this article, TWebZip is available for free through our

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

and you can download it from

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

.

To install, open, compile & install the package from the "Component Library Source" folder. This will install the design-time TWebZip component.
For use at runtime, make sure that the "Core Source" folder is in your TMS WEB Core specific library path that you can set via IDE Tools, Options, TMS Web, Library path.


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

 
Вверх