File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ class Message implements ArrayableInterface
1212 private ?string $ username = null ;
1313 private bool $ tts = false ;
1414 private ?string $ file = null ;
15+ private ?string $ filename = null ;
1516
1617 private SplObjectStorage $ embeds ;
1718
@@ -80,6 +81,18 @@ public function setFile(?string $file): self
8081 return $ this ;
8182 }
8283
84+ public function getFilename (): ?string
85+ {
86+ return $ this ->filename ;
87+ }
88+
89+ public function setFilename (?string $ filename ): self
90+ {
91+ $ this ->filename = $ filename ;
92+
93+ return $ this ;
94+ }
95+
8396 public function getEmbeds (): SplObjectStorage
8497 {
8598 return $ this ->embeds ;
@@ -133,6 +146,7 @@ public function toArray(): array
133146
134147 if ($ this ->file !== null ) {
135148 $ data ['file ' ] = $ this ->file ;
149+ $ data ['filename ' ] = $ this ->filename ?? basename ($ this ->file );
136150 }
137151
138152 return $ data ;
Original file line number Diff line number Diff line change @@ -34,11 +34,13 @@ public function send(Message $message): int
3434 try {
3535 if (isset ($ data ['file ' ])) {
3636 $ file = $ data ['file ' ];
37- unset($ data ['file ' ]);
37+ $ filename = $ data ['filename ' ];
38+
39+ unset($ data ['file ' ], $ data ['filename ' ]);
3840
3941 $ options [CURLOPT_HTTPHEADER ] = ['Content-type: multipart/form-data ' ];
4042 $ options [CURLOPT_POSTFIELDS ] = [
41- 'file ' => new CURLFile ($ file , '' , basename ( $ file ) ),
43+ 'file ' => new CURLFile ($ file , '' , $ filename ),
4244 'payload_json ' => json_encode ($ data , JSON_THROW_ON_ERROR ),
4345 ];
4446 } else {
You can’t perform that action at this time.
0 commit comments