IPWorks Cloud 2020 Delphi Edition

Questions / Feedback?

UploadFile Method

Uploads a file.

function UploadFile(BucketId: String; FileName: String): String;

Remarks

This method uploads a new file named FileName to the bucket specified by BucketId, and returns the Id of the newly-created file.

The value passed for FileName must comply with the following restrictions:

  • Cannot contain non-printable or DEL characters (i.e., character codes below 32 or equal to 127, respectively).
  • Cannot contain backslashes (\).
  • Cannot begin or end with a slash (/), and cannot contain two subsequent slashes (//).
  • No segment (i.e., a part between slashes) can be more than 250 bytes long (when UTF-8 encoded).
  • The overall string can be no more than 1024 bytes long overall (when UTF-8 encoded).

If a file with the specified FileName already exists in the destination bucket, a new version of it is created.

The following information is also included in the request, and will be applied to the newly-created file:

  • All metadata items present in the Metadata* properties. Keep in mind that the server enforces a limit of 10 metadata items per file.
  • If the ClientModifiedTime configuration setting is non-empty: an additional metadata item with its value (which does count towards the 10 item limit).
  • The value of the ContentType property.

If SetUploadStream has been used to set an upload stream, it will take priority as the data source. If LocalFile is set the file will be uploaded from the specified path. If LocalFile is not set the data in FileData will be used.

To encrypt the file before uploading it, set EncryptionAlgorithm and EncryptionPassword.

The currently-authenticated application key must have the writeFiles capability to call this method successfully, otherwise the server will return an error. Refer to the Capabilities property for more information.

Automatic Multipart Uploads

If more than SimpleUploadLimit bytes of data are provided, the component will automatically perform a multipart upload by splitting the data up into parts (sized according to the FragmentSize configuration setting) and uploading them individually. To accomplish this, the component automatically makes calls to StartMultipartUpload, UploadPart, and CompleteMultipartUpload internally; tracks upload state information using the ResumableUploadState configuration setting; and tracks how much data has been uploaded using the StartByte property. The FragmentComplete event will fire after each part is uploaded.

If, during an automatic multipart upload, any individual request fails, the upload can be resumed be calling this method again with the same parameters, so long as ResumableUploadState and StartByte contain the same values as they did when the upload was interrupted.

When an automatic multipart upload completes successfully, ResumableUploadState is cleared and StartByte is reset to 0.

Copyright (c) 2022 /n software inc. - All rights reserved.
IPWorks Cloud 2020 Delphi Edition - Version 20.0 [Build 8265]