mirror of
https://github.com/strapi/strapi.git
synced 2025-08-30 11:45:48 +00:00
fixed input field to password type
This commit is contained in:
parent
541b00041a
commit
cbbce676ce
@ -1,4 +1,4 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Module dependencies
|
||||
@ -7,61 +7,64 @@
|
||||
// Public node modules.
|
||||
/* eslint-disable import/no-unresolved */
|
||||
/* eslint-disable prefer-template */
|
||||
const cloudinary = require('cloudinary').v2;
|
||||
const intoStream = require('into-stream');
|
||||
const cloudinary = require("cloudinary").v2;
|
||||
const intoStream = require("into-stream");
|
||||
|
||||
module.exports = {
|
||||
provider: 'cloudinary',
|
||||
name: 'Cloudinary',
|
||||
provider: "cloudinary",
|
||||
name: "Cloudinary",
|
||||
auth: {
|
||||
cloud_name: {
|
||||
label: 'Cloud name',
|
||||
type: 'text'
|
||||
label: "Cloud name",
|
||||
type: "text",
|
||||
},
|
||||
api_key: {
|
||||
label: 'API Key',
|
||||
type: 'text'
|
||||
label: "API Key",
|
||||
type: "text",
|
||||
},
|
||||
api_secret: {
|
||||
label: 'API Secret',
|
||||
type: 'text'
|
||||
}
|
||||
label: "API Secret",
|
||||
type: "password",
|
||||
},
|
||||
},
|
||||
init: (config) => {
|
||||
init: config => {
|
||||
cloudinary.config({
|
||||
cloud_name: config.cloud_name,
|
||||
api_key: config.api_key,
|
||||
api_secret: config.api_secret
|
||||
api_secret: config.api_secret,
|
||||
});
|
||||
|
||||
return {
|
||||
upload (file) {
|
||||
upload(file) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const upload_stream = cloudinary.uploader.upload_stream({ resource_type: "auto" }, (err, image) => {
|
||||
if (err) {
|
||||
return reject(err);
|
||||
}
|
||||
file.public_id = image.public_id;
|
||||
file.url = image.secure_url;
|
||||
resolve();
|
||||
});
|
||||
const upload_stream = cloudinary.uploader.upload_stream(
|
||||
{ resource_type: "auto" },
|
||||
(err, image) => {
|
||||
if (err) {
|
||||
return reject(err);
|
||||
}
|
||||
file.public_id = image.public_id;
|
||||
file.url = image.secure_url;
|
||||
resolve();
|
||||
},
|
||||
);
|
||||
intoStream(file.buffer).pipe(upload_stream);
|
||||
});
|
||||
},
|
||||
async delete (file) {
|
||||
async delete(file) {
|
||||
try {
|
||||
const response = await cloudinary.uploader.destroy(file.public_id, {
|
||||
invalidate: true
|
||||
invalidate: true,
|
||||
});
|
||||
if (response.result !== 'ok') {
|
||||
if (response.result !== "ok") {
|
||||
throw {
|
||||
error: new Error(response.result)
|
||||
error: new Error(response.result),
|
||||
};
|
||||
}
|
||||
} catch (error) {
|
||||
throw error.error;
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
},
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user