mirror of
https://github.com/strapi/strapi.git
synced 2025-11-12 16:22:10 +00:00
Merge pull request #3196 from strapi/cloudinary-password
Cloudinary provider plugin secret field now password type
This commit is contained in:
commit
1d172fa4ff
@ -16,52 +16,55 @@ module.exports = {
|
|||||||
auth: {
|
auth: {
|
||||||
cloud_name: {
|
cloud_name: {
|
||||||
label: 'Cloud name',
|
label: 'Cloud name',
|
||||||
type: 'text'
|
type: 'text',
|
||||||
},
|
},
|
||||||
api_key: {
|
api_key: {
|
||||||
label: 'API Key',
|
label: 'API Key',
|
||||||
type: 'text'
|
type: 'text',
|
||||||
},
|
},
|
||||||
api_secret: {
|
api_secret: {
|
||||||
label: 'API Secret',
|
label: 'API Secret',
|
||||||
type: 'text'
|
type: 'password',
|
||||||
}
|
|
||||||
},
|
},
|
||||||
init: (config) => {
|
},
|
||||||
|
init: config => {
|
||||||
cloudinary.config({
|
cloudinary.config({
|
||||||
cloud_name: config.cloud_name,
|
cloud_name: config.cloud_name,
|
||||||
api_key: config.api_key,
|
api_key: config.api_key,
|
||||||
api_secret: config.api_secret
|
api_secret: config.api_secret,
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
upload (file) {
|
upload(file) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const upload_stream = cloudinary.uploader.upload_stream({ resource_type: "auto" }, (err, image) => {
|
const upload_stream = cloudinary.uploader.upload_stream(
|
||||||
|
{ resource_type: 'auto' },
|
||||||
|
(err, image) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
return reject(err);
|
return reject(err);
|
||||||
}
|
}
|
||||||
file.public_id = image.public_id;
|
file.public_id = image.public_id;
|
||||||
file.url = image.secure_url;
|
file.url = image.secure_url;
|
||||||
resolve();
|
resolve();
|
||||||
});
|
},
|
||||||
|
);
|
||||||
intoStream(file.buffer).pipe(upload_stream);
|
intoStream(file.buffer).pipe(upload_stream);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
async delete (file) {
|
async delete(file) {
|
||||||
try {
|
try {
|
||||||
const response = await cloudinary.uploader.destroy(file.public_id, {
|
const response = await cloudinary.uploader.destroy(file.public_id, {
|
||||||
invalidate: true
|
invalidate: true,
|
||||||
});
|
});
|
||||||
if (response.result !== 'ok') {
|
if (response.result !== 'ok') {
|
||||||
throw {
|
throw {
|
||||||
error: new Error(response.result)
|
error: new Error(response.result),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw error.error;
|
throw error.error;
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user