How to use the minio.CopyConditions function in minio

To help you get started, we’ve selected a few minio examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github minio / minio-js / examples / copy-object.js View on Github external
* limitations under the License.
 */

 // Note: YOUR-ACCESSKEYID, YOUR-SECRETACCESSKEY, my-bucketname, my-objectname,
 // my-src-bucketname and my-src-objectname are dummy values, please replace
 // them with original values.

var Minio = require('minio')

var s3Client = new Minio.Client({
  endPoint: 's3.amazonaws.com',
  accessKey: 'YOUR-ACCESSKEYID',
  secretKey: 'YOUR-SECRETACCESSKEY'
}) 

var conds = new Minio.CopyConditions()
conds.setMatchETag('bd891862ea3e22c93ed53a098218791d')

s3Client.copyObject('my-bucketname', 'my-objectname', '/my-src-bucketname/my-src-objectname', conds, function(e, data) {
  if (e) {
    return console.log(e)
  }
  console.log("Successfully copied the object:")
  console.log("etag = " + data.etag + ", lastModified = " + data.lastModified)
})
github fullstack-build / fullstack-one / packages / file-storage / dist / index.js View on Github external
throw new Error(`A verifier for type '${type}' hasn't been defined.`);
                }
                if (type !== fName.type) {
                    throw new Error(`FileTypes do not match. Have you changed the fileName? The type should be '${type}'`);
                }
                try {
                    stat = yield this.client.statObject(this.fileStorageConfig.bucket, fName.uploadName);
                }
                catch (e) {
                    if (e.message.toLowerCase().indexOf("not found") >= 0) {
                        throw new Error("Please upload a file before verifying.");
                    }
                    throw e;
                }
                const verifyFileName = fName.createTempName();
                const verifyCopyConditions = new Minio.CopyConditions();
                verifyCopyConditions.setMatchETag(stat.etag);
                yield this.client.copyObject(this.fileStorageConfig.bucket, verifyFileName, `/${this.fileStorageConfig.bucket}/${fName.uploadName}`, verifyCopyConditions);
                yield this.verifierObjects[type].verify(verifyFileName, fName);
                yield this.auth.userQuery(context.accessToken, "SELECT _meta.file_verify($1);", [fName.id]);
                // Try to clean up temp objects. However, don't care if it fails.
                try {
                    yield this.client.removeObjects(this.fileStorageConfig.bucket, [fName.uploadName, verifyFileName]);
                }
                catch (err) {
                    this.logger.warn("verifyFile.removeObjectsFail", err);
                }
                const verifier = this.verifierObjects[fName.type];
                const objectNames = verifier.getObjectNames(fName);
                const cacheSettings = verifier.getObjectCacheSettings(fName);
                const objects = objectNames.map((object) => {
                    return {
github fullstack-build / fullstack-one / packages / file-storage / lib / DefaultVerifier.ts View on Github external
public async verify(verifyFileName: string, fileName: FileName) {
    try {
      const stat = await this.client.statObject(this.bucket, verifyFileName);

      const copyConditions = new Minio.CopyConditions();
      copyConditions.setMatchETag(stat.etag);

      await this.client.copyObject(this.bucket, fileName.name, `/${this.bucket}/${verifyFileName}`, copyConditions);
    } catch (e) {
      if (e.message.toLowerCase().indexOf("not found") >= 0) {
        throw new Error("Please upload a file before verifying.");
      }
      throw e;
    }
  }
github fullstack-build / fullstack-one / packages / file-storage / lib / index.ts View on Github external
if (type !== fileName.type) {
      throw new UserInputError(`FileTypes do not match. Have you changed the fileName? The type should be '${type}'`, { exposeDetails: true });
    }

    try {
      stat = await this.client.statObject(this.fileStorageConfig.bucket, fileName.uploadName);
    } catch (e) {
      if (e.message.toLowerCase().indexOf("not found") >= 0) {
        throw new UserInputError("Please upload a file before verifying.", { exposeDetails: true });
      }
      throw e;
    }

    const verifyFileName = fileName.createTempName();

    const verifyCopyConditions = new Minio.CopyConditions();
    verifyCopyConditions.setMatchETag(stat.etag);

    await this.client.copyObject(
      this.fileStorageConfig.bucket,
      verifyFileName,
      `/${this.fileStorageConfig.bucket}/${fileName.uploadName}`,
      verifyCopyConditions
    );

    await this.verifierObjects[type].verify(verifyFileName, fileName);

    if (accessToken != null) {
      await this.auth.getAuthQueryHelper().userQuery(accessToken, "SELECT _meta.file_verify($1);", [fileName.id]);
    } else {
      await this.auth.getAuthQueryHelper().query("SELECT _meta.file_verify($1);", [fileName.id]);
    }
github fullstack-build / fullstack-one / packages / file-storage / dist / defaultVerifier.js View on Github external
return __awaiter(this, void 0, void 0, function* () {
            try {
                const stat = yield this.client.statObject(this.bucket, verifyFileName);
                const copyConditions = new Minio.CopyConditions();
                copyConditions.setMatchETag(stat.etag);
                yield this.client.copyObject(this.bucket, fName.name, `/${this.bucket}/${verifyFileName}`, copyConditions);
            }
            catch (e) {
                if (e.message.toLowerCase().indexOf("not found") >= 0) {
                    throw new Error("Please upload a file before verifying.");
                }
                throw e;
            }
        });
    }

minio

S3 Compatible Cloud Storage client

Apache-2.0
Latest version published 4 days ago

Package Health Score

89 / 100
Full package analysis