Notify when there is a missing photo

  

In an android app that I made with Delphi I want to show photos from the database. When there is are 10 photos and let’s say 2 are missing I want to show a message which photos are missing and continue to show the 8 photos that are available.
So the filename is in the database but the real photo cant be found in the file.
This is the code on the client side
procedure TfmMain.Button42Click(Sender: TObject);
VAR
i : Integer;
FN : String;
begin
GetObjectFoto(Dm.mtObject.FieldByName(‘follownr’).value);
TV1.Items.Clear;
if dm.mtObjectphoto.RecordCount>0 then
begin
DM.mtObjectphoto.First;

for I := 0 to DM.mtObjectphoto.RecordCount-1 do
Begin
FN := ffotopath+DM.mtObjectphoto.FieldByName(‘filename’).Value;
If not (system.SysUtils.fileexists(FN)) then
try
DownloadFile(DM.mtObjectphoto.FieldByName(‘filename’).Value);
TV1.Items.Add;
TV1.Items.Items[i].Bitmap.LoadFromFile(fn);
TV1.Items.Items[i].Caption := ‘photo’;

end;

DM.mtObjectphoto.Next;
End;
end;

With ‘getobjectfoto’ i call the database for gathering the photos that belong to the object
this is the ‘downloadfile’ on the server-side
Begin
if fileexists(fphotomap+FilenameAtServer) then

Begin
Result := TMemoryStream.Create;
try
TMemoryStream(Result).LoadFromFile(fphotomap+FilenameAtServer);
FileSize := Result.Size;
Result.Position := 0;
except
FileSize := -1;

end;
End;

end;

fphotomap is just a directory on the server lets say C:\test
filenameatserver is the photoname that is saved in the database
Again the photo is not in the map but the data is in the database.
If i missed important data please let me know i correct it asap.

Comments are closed.