Skip to content

uploadFile

Sahri Riza Umami edited this page Jul 1, 2018 · 3 revisions

Asynchronously uploads a file to the cloud without sending it in a message.
updateFile will be used to notify about upload progress and successful completion of the upload.
The file will not have a persistent remote identifier until it will be sent in a message.

uploadFile(file, file_type, priority, callback, data)
Field Type Description
file InputFile File to upload.
file_type FileType File type: None, Animation, Audio, Document, Photo, ProfilePhoto, Secret, Sticker, Thumbnail, Unknown, Video, VideoNote, VoiceNote, Wallpaper or SecretThumbnail.
priority int32 Priority of the upload (1-32). The higher the priority, the earlier the file will be uploaded. If the priorities of two files are equal, then the first one for which uploadFile was called will be uploaded first.

Example

  • Asynchronously uploads file /tmp/photo.jpg to the cloud without sending it in a message with highest priority.

    uploadFile('/tmp/photo.jpg', 'Photo', 32)

    Response:

    {
      ["@type"] = "file",
      expected_size = 47812,
      id = 15,
      ["local"] = {
        ["@type"] = "localFile",
        can_be_deleted = false,
        can_be_downloaded = false,
        downloaded_prefix_size = 47812,
        downloaded_size = 47812,
        is_downloading_active = false,
        is_downloading_completed = true,
        path = "/tmp/photo.jpg"
      },
      remote = {
        ["@type"] = "remoteFile",
        id = "",
        is_uploading_active = true,
        is_uploading_completed = false,
        uploaded_size = 47812
      },
      size = 47812
    }

Frequently Asked Questions
The Functions

Clone this wiki locally