Notice

The forum is in read only mode.

  • Page:
  • 1
  • 2

TOPIC: Kinvey and https

Kinvey and https 7 years 2 months ago #1519

I did and I cannot express enough how helpful they were. But I could not figure out the https issue and how to stop the REST Request Timed Out error message when uploading a file (so I could give something more meaningful). So I appreciate your help.

BTW, XE8 is amazing. The speed of the compiler is awesome. Our app is quite complex and before I had to constantly restart XE7 because of crashing, even after just changing a line of code. So such thing now. So whatever internal changes were made in XE8 have really made it a great development environment. So so happy I upgraded!

Kinvey and https 7 years 2 months ago #1528

Hi Alex,

I am still checking on this. I will reply as soon as I have more info.

Regards,
Sarina

Kinvey and https 7 years 2 months ago #1529

Hi Alex,

Happy to hear you are liking XE8! Thanks for the great feedback.

Regards,
Sarina

Kinvey and https 7 years 2 months ago #1643

Hi Alex,

For the time out message, you should be able to catch the exception and display your own message.
Regarding https, you can use either 'http:' or 'https:' when making a request to Google. Kinvey uses Google cloud storage for files.
Here's some info from Kinvey on it: devcenter.kinvey.com/rest/guides/files#S...communicatingwithGCS

So, the solution is to modify the URLs we get from Kinvey to have an 'https:' prefix. You will need to edit the
REST.Backend.KinveyAPI source file found in source/data/rest/.

I would recommend saving a copy of the file in the same folder as your project. Then add the file to your project in Delphi XE8, and select to use
the unit.

Here are the changes you will need to make to the REST.Backend.KinveyAPI source file:

1. We need a routine to change the prefix. Add this routine somewhere:

function ForceHTTPS(const AURL: string): string;
begin
if AURL.StartsWith('http:') then
Result := 'https:' + AURL.Substring(5)
else
Result := AURL;
end;


2. Modify the URL for upload (in TKinveyApi.RetrieveFile):

LJSONValue := LResponseObject.GetValue('_uploadURL'); // Do not localize
if LJSONValue <> nil then
LUploadURL := LJSONValue.Value;
Assert(LUploadURL <> '');

// Change to HTTPS
LUploadURL := ForceHTTPS(LUploadURL);


3. Modify the URL to download (TKinveyAPI.RetrieveFile):

LResponse := FRequest.Response.JSONValue as TJSONObject;
AFile := FileFromObject(LResponse);
// Change to HTTPS
AFile.FDownloadURL := ForceHTTPS(AFile.FDownloadURL);
if Assigned(AJSON) then
AJSON.AddElement(LResponse.Clone as TJSONObject);
if Assigned(AProc) then
AProc(AFile, LResponse);
end
end;


Regards,
Sarina

Kinvey and https 7 years 2 months ago #1644

Thank you so much for your help. I truly appreciate it.

Kinvey and https 7 years 2 months ago #1645

You're welcome!
  • Page:
  • 1
  • 2
Moderators: April Anne