File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -743,7 +743,7 @@ class _StickerPackEditorScreenState extends State<StickerPackEditorScreen> {
743743 if (accepted != true || slugText.isEmpty) return ;
744744 setState (() => _busy = true );
745745 try {
746- final uploaded = await TfApiClient .instance.uploadFile (
746+ final uploaded = await TfApiClient .instance.uploadSticker (
747747 uid,
748748 password,
749749 file.name,
Original file line number Diff line number Diff line change @@ -1779,6 +1779,11 @@ class TfApiClient {
17791779 return '$baseUrl /file/get_file/${Uri .encodeComponent (hash )}' ;
17801780 }
17811781
1782+ Future <String > getStickerUrl (String hash) async {
1783+ final baseUrl = await getBaseUrl ();
1784+ return '$baseUrl /sticker/get/${Uri .encodeComponent (hash )}' ;
1785+ }
1786+
17821787 Future <String > getTextFile (String url) async {
17831788 final response = await _getRequest (url);
17841789 if (response.statusCode < 200 || response.statusCode >= 300 ) {
@@ -2435,6 +2440,28 @@ class TfApiClient {
24352440 return data;
24362441 }
24372442
2443+ Future <Map <String , dynamic >?> uploadSticker (
2444+ int uid,
2445+ String password,
2446+ String fileName,
2447+ String fileBase64,
2448+ ) async {
2449+ final result = await secretPost (
2450+ '/sticker/upload' ,
2451+ {'filename' : fileName, 'file_b64' : fileBase64},
2452+ uid: uid,
2453+ password: password,
2454+ );
2455+
2456+ final data = _parseJsonMap (result);
2457+ if (data == null ) return null ;
2458+
2459+ final success = data['success' ];
2460+ if (success is bool && ! success) return null ;
2461+
2462+ return data;
2463+ }
2464+
24382465 Future <List <Map <String , dynamic >>> getUserFiles (
24392466 int uid,
24402467 String password,
Original file line number Diff line number Diff line change @@ -87,7 +87,7 @@ class _StickerImageState extends State<StickerImage> {
8787
8888 await _acquireDownloadSlot ();
8989 try {
90- final url = await TfApiClient .instance.getFileUrl (widget.hash);
90+ final url = await TfApiClient .instance.getStickerUrl (widget.hash);
9191 final response =
9292 await http.get (Uri .parse (url)).timeout (const Duration (seconds: 15 ));
9393 if (response.statusCode < 200 || response.statusCode >= 300 ) {
You can’t perform that action at this time.
0 commit comments