REST.Backend.KinveyApi.TKinveyApi.UploadFile

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

procedure UploadFile(const AFileName: string; AContentType: string; APublic: Boolean; const AUserFields: TJSONObject; out ANewFile: TFile); overload;
procedure UploadFile(const AFileName: string; const AStream: TStream; AContentType: string; APublic: Boolean; const AUserFields: TJSONObject; out ANewFile: TFile); overload;

C++

void __fastcall UploadFile(const System::UnicodeString AFileName, System::UnicodeString AContentType, bool APublic, System::Json::TJSONObject* const AUserFields, /* out */ TFile &ANewFile)/* overload */;
void __fastcall UploadFile(const System::UnicodeString AFileName, System::Classes::TStream* const AStream, System::UnicodeString AContentType, bool APublic, System::Json::TJSONObject* const AUserFields, /* out */ TFile &ANewFile)/* overload */;

Properties

Type Visibility Source Unit Parent
procedure
function
public
REST.Backend.KinveyApi.pas
REST.Backend.KinveyApi.hpp
REST.Backend.KinveyApi TKinveyApi

Description

Uploads a file to Kinvey.

The UploadFile method takes the following parameters:

Parameter Description
AFileName The string containing the file name.
AContentType The string indicating the type of content of the file.
APublic By default files uploaded to Kinvey are private. Set this parameter to True to create a publicity-readable file. Uploading the file as public-readable means that the download link to this file will be a regular non-signed URL that does not expire until the file is deleted or until it is set to private.
AUserFields TJSONObject included in the TRESTRequest.
ANewFile Output parameter of type TFile to store information about the file.
AStream The TStream with the file to upload.
Note: This argument is only for the second overloaded method.

The first UploadFile overloaded method takes the first five parameters of the above table, creates a TFileStream with the AFileName and calls the second overloaded method adding the TFileStream as the AStream parameter.

Uploading files to Kinvey needs two steps:

  1. UploadFile sends a POST request to Kinvey in order to retrieve the upload URL where the file can be uploaded to. This first step does not upload the content of the file, it only retrieves the upload URL.
  2. Then, UploadFile sends a PUT request to Kinvey indicating with the upload URL and sending the file content.

Note: Kinvey uses Google Cloud Storage to store the files.

See Also