InputFile
in package
implements
Stringable
FinalYes
A file to upload - the `InputFile` of the Bot API.
Pass one anywhere the spec accepts InputFile or String, at any depth, and the
call switches itself to multipart/form-data:
$telegram->sendPhoto($chatId, InputFile::fromPath('cat.jpg'), caption: 'mine');
Sending a file_id or an HTTP URL needs none of this - pass the plain string.
Tags
Table of Contents
Interfaces
- Stringable
Properties
- $contents : ?string
- $contentType : ?string
- $filename : string
- $path : ?string
Methods
- __toString() : string
- attachName() : string
- The `attach://` form a nested upload is referenced by.
- fromPath() : self
- Reads the upload from disk when the request is encoded.
- fromStream() : self
- Drains a stream resource into the upload.
- fromString() : self
- Uploads bytes already in memory.
- getContents() : string
- The bytes to send, read from disk on first use.
- getContentType() : ?string
- The declared MIME type, guessed from the file when one was not given.
- getFilename() : string
- getPath() : ?string
- __construct() : mixed
Properties
$contents read-only
private
?string
$contents
$contentType read-only
private
?string
$contentType
$filename read-only
private
string
$filename
$path read-only
private
?string
$path
Methods
__toString()
public
__toString() : string
Return values
stringattachName()
The `attach://` form a nested upload is referenced by.
public
attachName() : string
Return values
stringfromPath()
Reads the upload from disk when the request is encoded.
public
static fromPath(string $path[, ?string $filename = null ][, ?string $contentType = null ]) : self
Parameters
- $path : string
- $filename : ?string = null
- $contentType : ?string = null
Tags
Return values
selffromStream()
Drains a stream resource into the upload.
public
static fromStream(resource $stream, string $filename[, ?string $contentType = null ]) : self
Parameters
- $stream : resource
- $filename : string
- $contentType : ?string = null
Return values
selffromString()
Uploads bytes already in memory.
public
static fromString(string $contents, string $filename[, ?string $contentType = null ]) : self
Parameters
- $contents : string
- $filename : string
- $contentType : ?string = null
Return values
selfgetContents()
The bytes to send, read from disk on first use.
public
getContents() : string
Return values
stringgetContentType()
The declared MIME type, guessed from the file when one was not given.
public
getContentType() : ?string
Return values
?stringgetFilename()
public
getFilename() : string
Return values
stringgetPath()
public
getPath() : ?string
Return values
?string__construct()
private
__construct(?string $path, ?string $contents, string $filename, ?string $contentType) : mixed
Parameters
- $path : ?string
- $contents : ?string
- $filename : string
- $contentType : ?string