@kevisual/oss 0.0.2 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -121,7 +121,14 @@ declare class OssBase implements OssBaseOperation {
121
121
  startAfter?: string;
122
122
  }): Promise<IS_FILE extends true ? ListFileObject[] : ListObjectResult[]>;
123
123
  fPutObject(objectName: string, filePath: string, metaData?: ItemBucketMetadata): Promise<any>;
124
- statObject(objectName: string): Promise<minio.BucketItemStat>;
124
+ statObject(objectName: string, checkFile?: boolean): Promise<minio.BucketItemStat>;
125
+ /**
126
+ * 检查文件hash是否一致
127
+ * @param objectName
128
+ * @param hash
129
+ * @returns
130
+ */
131
+ checkFileHash(objectName: string, hash: string): Promise<boolean>;
125
132
  copyObject(sourceObject: any, targetObject: any): Promise<minio_dist_esm_internal_type_mjs.CopyObjectResult>;
126
133
  replaceObject(objectName: string, meta: {
127
134
  [key: string]: string;
@@ -133,4 +140,4 @@ declare class OssBase implements OssBaseOperation {
133
140
  }): T;
134
141
  }
135
142
 
136
- export { type ListFileObject as L, OssBase as O, type OssBaseOptions as a, type OssService as b, type ListObjectResult as c };
143
+ export { type ListFileObject as L, OssBase as O, type StatObjectResult as S, type UploadedObjectInfo as U, type OssBaseOptions as a, type ListDirectoryObject as b, type ListObjectResult as c, type OssBaseOperation as d, type OssService as e };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  import 'minio';
2
2
  import 'minio/dist/esm/internal/type.mjs';
3
3
  import 'stream';
4
- export { O as OssBase, a as OssBaseOptions } from './index-CQoepWCw.js';
4
+ export { O as OssBase, a as OssBaseOptions } from './index-z-16S9o1.js';
package/dist/index.js CHANGED
@@ -117,10 +117,13 @@ var OssBase = class {
117
117
  const obj = await this.client.fPutObject(bucketName, `${this.prefix}${objectName}`, filePath, metaData);
118
118
  return obj;
119
119
  }
120
- async statObject(objectName) {
120
+ async statObject(objectName, checkFile = true) {
121
121
  const bucketName = this.bucketName;
122
122
  try {
123
123
  const obj = await this.client.statObject(bucketName, `${this.prefix}${objectName}`);
124
+ if (obj && checkFile && obj.size === 0) {
125
+ return null;
126
+ }
124
127
  return obj;
125
128
  } catch (e) {
126
129
  if (e.code === "NotFound") {
@@ -129,6 +132,19 @@ var OssBase = class {
129
132
  throw e;
130
133
  }
131
134
  }
135
+ /**
136
+ * 检查文件hash是否一致
137
+ * @param objectName
138
+ * @param hash
139
+ * @returns
140
+ */
141
+ async checkFileHash(objectName, hash2) {
142
+ const obj = await this.statObject(`${this.prefix}${objectName}`, true);
143
+ if (!obj) {
144
+ return false;
145
+ }
146
+ return obj.etag === hash2;
147
+ }
132
148
  async copyObject(sourceObject, targetObject) {
133
149
  const bucketName = this.bucketName;
134
150
  const obj = await this.client.copyObject(bucketName, sourceObject, targetObject);
@@ -1,5 +1,5 @@
1
1
  import * as minio_dist_esm_internal_type_mjs from 'minio/dist/esm/internal/type.mjs';
2
- import { O as OssBase, b as OssService, a as OssBaseOptions, L as ListFileObject, c as ListObjectResult } from '../index-CQoepWCw.js';
2
+ import { O as OssBase, e as OssService, a as OssBaseOptions, L as ListFileObject, c as ListObjectResult } from '../index-z-16S9o1.js';
3
3
  import 'minio';
4
4
  import 'stream';
5
5
 
@@ -120,10 +120,13 @@ var OssBase = class {
120
120
  const obj = await this.client.fPutObject(bucketName, `${this.prefix}${objectName}`, filePath, metaData);
121
121
  return obj;
122
122
  }
123
- async statObject(objectName) {
123
+ async statObject(objectName, checkFile = true) {
124
124
  const bucketName = this.bucketName;
125
125
  try {
126
126
  const obj = await this.client.statObject(bucketName, `${this.prefix}${objectName}`);
127
+ if (obj && checkFile && obj.size === 0) {
128
+ return null;
129
+ }
127
130
  return obj;
128
131
  } catch (e) {
129
132
  if (e.code === "NotFound") {
@@ -132,6 +135,19 @@ var OssBase = class {
132
135
  throw e;
133
136
  }
134
137
  }
138
+ /**
139
+ * 检查文件hash是否一致
140
+ * @param objectName
141
+ * @param hash
142
+ * @returns
143
+ */
144
+ async checkFileHash(objectName, hash2) {
145
+ const obj = await this.statObject(`${this.prefix}${objectName}`, true);
146
+ if (!obj) {
147
+ return false;
148
+ }
149
+ return obj.etag === hash2;
150
+ }
135
151
  async copyObject(sourceObject, targetObject) {
136
152
  const bucketName = this.bucketName;
137
153
  const obj = await this.client.copyObject(bucketName, sourceObject, targetObject);
@@ -1,5 +1,5 @@
1
- import { O as OssBase } from '../index-CQoepWCw.js';
2
- export { a as OssBaseOptions } from '../index-CQoepWCw.js';
1
+ import { O as OssBase } from '../index-z-16S9o1.js';
2
+ export { b as ListDirectoryObject, L as ListFileObject, c as ListObjectResult, d as OssBaseOperation, a as OssBaseOptions, e as OssService, S as StatObjectResult, U as UploadedObjectInfo } from '../index-z-16S9o1.js';
3
3
  export { ConfigOssService } from './config.js';
4
4
  import * as stream from 'stream';
5
5
  import { ServerResponse } from 'node:http';
@@ -120,10 +120,13 @@ var OssBase = class {
120
120
  const obj = await this.client.fPutObject(bucketName, `${this.prefix}${objectName}`, filePath, metaData);
121
121
  return obj;
122
122
  }
123
- async statObject(objectName) {
123
+ async statObject(objectName, checkFile = true) {
124
124
  const bucketName = this.bucketName;
125
125
  try {
126
126
  const obj = await this.client.statObject(bucketName, `${this.prefix}${objectName}`);
127
+ if (obj && checkFile && obj.size === 0) {
128
+ return null;
129
+ }
127
130
  return obj;
128
131
  } catch (e) {
129
132
  if (e.code === "NotFound") {
@@ -132,6 +135,19 @@ var OssBase = class {
132
135
  throw e;
133
136
  }
134
137
  }
138
+ /**
139
+ * 检查文件hash是否一致
140
+ * @param objectName
141
+ * @param hash
142
+ * @returns
143
+ */
144
+ async checkFileHash(objectName, hash2) {
145
+ const obj = await this.statObject(`${this.prefix}${objectName}`, true);
146
+ if (!obj) {
147
+ return false;
148
+ }
149
+ return obj.etag === hash2;
150
+ }
135
151
  async copyObject(sourceObject, targetObject) {
136
152
  const bucketName = this.bucketName;
137
153
  const obj = await this.client.copyObject(bucketName, sourceObject, targetObject);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kevisual/oss",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {