天翼云 判断文件存在跟删除 测试通过

This commit is contained in:
wkj 2024-07-15 12:48:22 +08:00
parent db5b28f751
commit c0ccf1892c
4 changed files with 17 additions and 17 deletions

View File

@ -207,7 +207,7 @@ export class CTYunInstance {
catch (err) { catch (err) {
throw new OakNetworkException(); throw new OakNetworkException();
} }
if (response.status === 204) { if (response.status === 204 || response.status === 200) {
return true; return true;
} }
const text = await response.text(); const text = await response.text();

View File

@ -211,7 +211,7 @@ class CTYunInstance {
catch (err) { catch (err) {
throw new Exception_1.OakNetworkException(); throw new Exception_1.OakNetworkException();
} }
if (response.status === 204) { if (response.status === 204 || response.status === 200) {
return true; return true;
} }
const text = await response.text(); const text = await response.text();

View File

@ -229,7 +229,7 @@ export class CTYunInstance {
} catch (err) { } catch (err) {
throw new OakNetworkException(); throw new OakNetworkException();
} }
if (response.status === 204) { if (response.status === 204 || response.status === 200) {
return true; return true;
} }
const text = await response.text(); const text = await response.text();

View File

@ -29,35 +29,35 @@ async function removeFile() {
} }
// isExistFile(); // isExistFile();
removeFile(); // removeFile();
const accessKey2 = ''; const accessKey2 = '';
const accessSecret2 = ''; const accessSecret2 = '';
async function removeCTYunFile() {
const instance = CTYunSDK.getInstance(accessKey2, accessSecret2);
const result = await instance.removeFile(
'jiupai-oss-dev',
'hbwh',
'fff.jpg'
);
console.log(result);
}
async function isExistCTYunFile() { async function isExistCTYunFile() {
const instance = CTYunSDK.getInstance(accessKey2, accessSecret2); const instance = CTYunSDK.getInstance(accessKey2, accessSecret2);
const result = await instance.isExistObject( const result = await instance.isExistObject(
'jiupai-oss-dev', 'jiupai-oss-dev',
'hbwh', 'hbwh',
'fff.jpg' 'extraFile/6e0d90fd-2df2-4c7d-b78b-1c1af1038db5.jpg'
); );
console.log(result); console.log(result);
} }
// removeCTYunFile(); async function removeCTYunFile() {
const instance = CTYunSDK.getInstance(accessKey2, accessSecret2);
const result = await instance.removeFile(
'jiupai-oss-dev',
'hbwh',
'extraFile/6e0d90fd-2df2-4c7d-b78b-1c1af1038db5.jpg'
);
console.log(result);
}
// isExistCTYunFile(); // isExistCTYunFile();
// removeCTYunFile();