Skip to content

Commit dc69e15

Browse files
committed
fix: #26 upload api changed
1 parent 2f591ed commit dc69e15

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

app/Coding.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public function upload(array $uploadToken, string $fileFullPath): bool
8888
config(['filesystems.disks.cos.region' => $uploadToken['Region']]);
8989
config(['filesystems.disks.cos.bucket' => $uploadToken['Bucket']]);
9090

91-
return Storage::disk('cos')->put(basename($fileFullPath), File::get($fileFullPath));
91+
return Storage::disk('cos')->put($uploadToken['StorageKey'], File::get($fileFullPath));
9292
}
9393

9494
public function createWikiByZip(string $token, string $projectName, array $uploadToken, array $data)

tests/Unit/CodingTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class CodingTest extends TestCase
1717
'SecretKey' => 'clUYSNeg2es16EILsrF6RyCD3ss6uFLX3Xgc=',
1818
'UploadLink' => 'https://coding-net-dev-file-123456.cos.ap-shanghai.myqcloud.com',
1919
'UpToken' => 'EOlMEc2x0xbrFoL9CMy7OqDl5413654938410a360a63207e30dab4655pMKmNJ3t5M-Z8bGt',
20+
'StorageKey' => 'b5d0d8e0-3aca-11eb-8673-a9b6d94ca755.zip',
2021
'Time' => 1625579588693,
2122
'Bucket' => 'coding-net-dev-file-123456',
2223
'AppId' => '123456',
@@ -126,7 +127,7 @@ public function testUpload()
126127
$coding = new Coding();
127128
$coding->upload(self::$uploadToken, $file);
128129

129-
Storage::disk('cos')->assertExists(basename($file));
130+
Storage::disk('cos')->assertExists(self::$uploadToken['StorageKey']);
130131
}
131132

132133
public function testGetImportJobStatus()

tests/data/coding/createUploadTokenResponse.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"SecretKey": "clUYSNeg2es16EILsrF6RyCD3ss6uFLX3Xgc=",
99
"UploadLink": "https://coding-net-dev-file-123456.cos.ap-shanghai.myqcloud.com",
1010
"UpToken": "EOlMEc2x0xbrFoL9CMy7OqDl5413654938410a360a63207e30dab4655pMKmNJ3t5M-Z8bGt",
11+
"StorageKey": "b5d0d8e0-3aca-11eb-8673-a9b6d94ca755.zip",
1112
"Time": 1625579588693
1213
}
1314
}

0 commit comments

Comments
 (0)