cloudi-upload-with-ease
Advanced tools
Comparing version 1.2.0 to 1.20.0
@@ -1,11 +0,10 @@ | ||
import { UploadApiResponse } from "cloudinary"; | ||
import { IImageFile, Iconfig, IUploadedResponse } from "../interface"; | ||
declare const uploadToCloudinary: (file: any, type: "image" | "video" | "raw" | "auto" | undefined, config: Iconfig, folderName?: string, transformation?: { | ||
crop: "scale"; | ||
quality: "auto"; | ||
import { UploadApiResponse } from 'cloudinary'; | ||
import { IImageFile, Iconfig, IUploadedResponse } from '../interface'; | ||
export declare const uploadToCloudinary: (file: any, type: 'image' | 'video' | 'raw' | 'auto' | undefined, config: Iconfig, folderName?: string, transformation?: { | ||
crop: 'scale'; | ||
quality: 'auto'; | ||
}, resourceId?: string) => Promise<UploadApiResponse>; | ||
declare const uploadSingleOrMultiImagesToClodinary: (files: IImageFile[], type: "image" | "video" | "raw" | "auto" | undefined, config: Iconfig, folderName?: string, transformation?: { | ||
crop: "scale"; | ||
quality: "auto"; | ||
export declare const uploadSingleOrMultiImagesToClodinary: (files: IImageFile[], type: 'image' | 'video' | 'raw' | 'auto' | undefined, config: Iconfig, folderName?: string, transformation?: { | ||
crop: 'scale'; | ||
quality: 'auto'; | ||
}, resourceId?: string) => Promise<IUploadedResponse | any>; | ||
export { uploadToCloudinary, uploadSingleOrMultiImagesToClodinary }; |
@@ -22,3 +22,3 @@ "use strict"; | ||
api_key: config.cloudinary_api_key, | ||
api_secret: config.cloudinary_api_secret, | ||
api_secret: config.cloudinary_api_secret | ||
}); | ||
@@ -33,6 +33,4 @@ try { | ||
folder: folderName || config.cloudinary_cloud_name, | ||
crop: transformation && transformation.crop ? transformation.crop : "scale", | ||
quality: transformation && transformation.quality | ||
? transformation.quality | ||
: "auto", | ||
crop: transformation && transformation.crop ? transformation.crop : 'scale', | ||
quality: transformation && transformation.quality ? transformation.quality : 'auto' | ||
}); | ||
@@ -52,3 +50,3 @@ resolve(uploadedResponse); | ||
//upload the first Image as the main product image | ||
singleImageRes = yield uploadToCloudinary(firstImage.path, type, config, folderName, transformation, resourceId); | ||
singleImageRes = yield (0, exports.uploadToCloudinary)(firstImage.path, type, config, folderName, transformation, resourceId); | ||
// console.log(singleImageRes, "singleImageRes"); | ||
@@ -58,9 +56,7 @@ //upload other images | ||
allImagesRes = yield Promise.all([firstImage, ...others].map((file) => __awaiter(void 0, void 0, void 0, function* () { | ||
return yield uploadToCloudinary(file.path, type, config); | ||
return yield (0, exports.uploadToCloudinary)(file.path, type, config); | ||
}))); | ||
// console.log(otherImagesRes, "otherImagesRes"); | ||
} | ||
const finalRes = allImagesRes.length > 0 | ||
? { singleImageRes, allImagesRes } | ||
: { singleImageRes }; | ||
const finalRes = allImagesRes && allImagesRes.length > 0 ? { singleImageRes, allImagesRes } : { singleImageRes }; | ||
return finalRes; | ||
@@ -67,0 +63,0 @@ }); |
@@ -18,3 +18,2 @@ "use strict"; | ||
__exportStar(require("./cloudinary"), exports); | ||
console.log('hhhhhhhhhhhhhhhhhhhhhhhhhh'); | ||
//# sourceMappingURL=index.js.map |
@@ -1,11 +0,10 @@ | ||
import { UploadApiResponse } from "cloudinary"; | ||
import { IImageFile, Iconfig, IUploadedResponse } from "../interface"; | ||
declare const uploadToCloudinary: (file: any, type: "image" | "video" | "raw" | "auto" | undefined, config: Iconfig, folderName?: string, transformation?: { | ||
crop: "scale"; | ||
quality: "auto"; | ||
import { UploadApiResponse } from 'cloudinary'; | ||
import { IImageFile, Iconfig, IUploadedResponse } from '../interface'; | ||
export declare const uploadToCloudinary: (file: any, type: 'image' | 'video' | 'raw' | 'auto' | undefined, config: Iconfig, folderName?: string, transformation?: { | ||
crop: 'scale'; | ||
quality: 'auto'; | ||
}, resourceId?: string) => Promise<UploadApiResponse>; | ||
declare const uploadSingleOrMultiImagesToClodinary: (files: IImageFile[], type: "image" | "video" | "raw" | "auto" | undefined, config: Iconfig, folderName?: string, transformation?: { | ||
crop: "scale"; | ||
quality: "auto"; | ||
export declare const uploadSingleOrMultiImagesToClodinary: (files: IImageFile[], type: 'image' | 'video' | 'raw' | 'auto' | undefined, config: Iconfig, folderName?: string, transformation?: { | ||
crop: 'scale'; | ||
quality: 'auto'; | ||
}, resourceId?: string) => Promise<IUploadedResponse | any>; | ||
export { uploadToCloudinary, uploadSingleOrMultiImagesToClodinary }; |
@@ -10,4 +10,4 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
}; | ||
import cloudinary from "cloudinary"; | ||
const uploadToCloudinary = (file, type, config, folderName, transformation, resourceId) => __awaiter(void 0, void 0, void 0, function* () { | ||
import cloudinary from 'cloudinary'; | ||
export const uploadToCloudinary = (file, type, config, folderName, transformation, resourceId) => __awaiter(void 0, void 0, void 0, function* () { | ||
return new Promise((resolve, reject) => __awaiter(void 0, void 0, void 0, function* () { | ||
@@ -17,3 +17,3 @@ cloudinary.v2.config({ | ||
api_key: config.cloudinary_api_key, | ||
api_secret: config.cloudinary_api_secret, | ||
api_secret: config.cloudinary_api_secret | ||
}); | ||
@@ -28,6 +28,4 @@ try { | ||
folder: folderName || config.cloudinary_cloud_name, | ||
crop: transformation && transformation.crop ? transformation.crop : "scale", | ||
quality: transformation && transformation.quality | ||
? transformation.quality | ||
: "auto", | ||
crop: transformation && transformation.crop ? transformation.crop : 'scale', | ||
quality: transformation && transformation.quality ? transformation.quality : 'auto' | ||
}); | ||
@@ -41,3 +39,3 @@ resolve(uploadedResponse); | ||
}); | ||
const uploadSingleOrMultiImagesToClodinary = (files, type, config, folderName, transformation, resourceId) => __awaiter(void 0, void 0, void 0, function* () { | ||
export const uploadSingleOrMultiImagesToClodinary = (files, type, config, folderName, transformation, resourceId) => __awaiter(void 0, void 0, void 0, function* () { | ||
const [firstImage, ...others] = files; | ||
@@ -56,8 +54,5 @@ let singleImageRes; | ||
} | ||
const finalRes = allImagesRes.length > 0 | ||
? { singleImageRes, allImagesRes } | ||
: { singleImageRes }; | ||
const finalRes = allImagesRes && allImagesRes.length > 0 ? { singleImageRes, allImagesRes } : { singleImageRes }; | ||
return finalRes; | ||
}); | ||
export { uploadToCloudinary, uploadSingleOrMultiImagesToClodinary }; | ||
//# sourceMappingURL=index.js.map |
export * from './cloudinary'; | ||
console.log('hhhhhhhhhhhhhhhhhhhhhhhhhh'); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "cloudi-upload-with-ease", | ||
"version": "1.2.0", | ||
"version": "1.20.0", | ||
"description": "upload to cloudinary with ease", | ||
@@ -42,9 +42,8 @@ "main": "dist/cjs/index.js", | ||
"@types/node": "^20.10.4", | ||
"cloudinary": "^1.41.0", | ||
"ts-node-dev": "^2.0.0", | ||
"typescript": "^5.3.3" | ||
}, | ||
"peerDependencies": { | ||
"dependencies": { | ||
"cloudinary": "^1.41.0" | ||
} | ||
} |
@@ -22,3 +22,3 @@ # Cloudinary File Upload Utility for Node.js | ||
uploadToCloudinary, | ||
uploadSingleOrMultiImagesToCloudinary, | ||
uploadSingleOrMultiImagesToClodinary, | ||
} = require('cloudi-upload-with-ease'); | ||
@@ -30,3 +30,3 @@ ``` | ||
uploadToCloudinary, | ||
uploadSingleOrMultiImagesToCloudinary, | ||
uploadSingleOrMultiImagesToClodinary, | ||
} from 'cloudi-upload-with-ease'; | ||
@@ -73,3 +73,3 @@ ``` | ||
uploadSingleOrMultiImagesToCloudinary(files, type, config) | ||
uploadSingleOrMultiImagesToClodinary(files, type, config) | ||
.then((response) => { | ||
@@ -76,0 +76,0 @@ console.log('Files uploaded successfully:', response); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
4
17780
191
+ Addedcloudinary@^1.41.0