Skip to content

v2.0.0

Compare
Choose a tag to compare
@ChenglongMa ChenglongMa released this 13 Nov 04:03
· 25 commits to main since this release

Changelog

Ver 2.0.0

  1. Add resize options, which can compress the images before uploading.
        req.file('avatar')
        .upload({
          // Required
          adapter: require('skipper-gcstorage'),
          bucket: 'existing_or_new_bucket_name', // Will create new one if no such bucket exists.
          // Optional
          projectId: 'GOOGLE_CLOUD_PROJECT', // Mandatory if `keyFilename` was specified.
          keyFilename: '/path/to/GOOGLE_APPLICATION_CREDENTIALS.json', 
          bucketMetadata: {
            location: 'us-west1',
          },  // Refer to https://googleapis.dev/nodejs/storage/latest/global.html#CreateBucketRequest
          maxBytes: 60000, 
          metadata: {},
          public: true,
>>>>      resize: {                                                         // <<<<<<<<<<<<< new feature
            width: 500,
            height: 500
          }, // Refer to https://sharp.pixelplumbing.com/api-resize#resize
        }, function whenDone(err, uploadedFiles) {
          if (err) {
            return res.serverError(err);
          }
          return res.ok({
            files: uploadedFiles,
            textParams: req.params.all()
          });
        });