Get access to over 100 FireMonkey cross platform samples for Android, IOS, OSX, Windows, and Linux!

AndroidAppmethodCode SnippetDelphiDemoFiremonkeyIOSOSXWindows

Upload An Image With The BaaS Components For Delphi XE6 Firemonkey On Android And IOS

| Delphi 11 10 XE8 XE7 XE Seattle Berlin Tokyo Rio Firemonkey Delphi Android Delphi IOS

Delphi XE6 Firemonkey BaaS Image Uploader | Delphi 11 10 XE8 XE7 XE Seattle Berlin Tokyo Rio Firemonkey Delphi Android Delphi IOSSarina DuPont from Embarcadero has a blog post up with a tutorial for uploading and viewing images using the BaaS components in Delphi XE6 Firemonkey. Parse is the backend provider used in the tutorial. The main component is the TBackendFiles component which plugs into the provider component (in this case TParseProvider). You basically save your image to a TMemoryStream and pass that to the UploadFile function of TBackendFiles.Files. What is also interesting about this tutorial is that it shows how to use the response object which is a TBackendEntityValue to get the URL of the uploaded file. Here is the example upload code:
var
LStream: TStream;
LFile: TBackendEntityValue;
begin
LStream := SaveImage;
try
BackEndFiles1.Files.UploadFile(’mypicture3.png’,LStream, ‘image/png’,LFile);
ShowMessage(’Image has been uploaded’);
Edit1.Text := LFile.DownloadURL;

The download image function is also interesting and it downloads to a TMemoryStream as well before loading it into a bitmap. The download code snippet is here:
var
LStream: TMemoryStream;
begin
LStream := TMemoryStream.Create;
try
REST.Client.TDownloadURL.DownloadRawBytes(AUrl, LStream);
Image2.Bitmap.LoadFromStream(LStream);
finally
LStream.Free;
end;

Head over and check out the full tutorial on how to upload an image using the BaaS components and then download and view the same image.

Have Delphi Firemonkey questions? Ask and get answers on StackOverflow.

Related posts
DelphiDemoFiremonkeyLinuxOSXShowcaseWindows

AutoBlogAI: FireMonkey Client To Leverage LLMs And Generative AI For Blogging

DelphiFiremonkeyShowcaseUtilityWindows

Unleashing Creativity With Song Writer AI: A Deep Dive

DelphiFiremonkeyShowcaseWindows

How To Build Stable Diffusion Text To Image Prompts

AndroidC++BuilderDelphiFiremonkeyIOSOSXWindows

FireMonkey 10.4.2 Features Updated iOS 14, Android 11, And macOS 11 Support Plus Hundreds Of Fixes

Sign up for our Newsletter and
stay informed

5 Comments

Leave a Reply