所以我可以通过http://cloudinary.com/blog/direct_upload_made_easy_from_browser_or_mobile_app_to_the_cloud#face_detection_based_thumbnail中基于表单的方法将图像上传到Cloudinary ,但是当我尝试扩充现有文件输入时,它会给我进度说文件正在上传,但是错误说明文件丢失了.
{"error":{"message":"Missing required parameter - file"}}
Run Code Online (Sandbox Code Playgroud)
js代码是:
Template.fileUpload.created = function () {
$.cloudinary.config({
cloud_name: "theCloudName"
})
};
Template.fileUpload.rendered = function () {
var fileUploadCallback = function(err, result){
if(err){
console.log("Error: " + err.reason);
}else{
console.log("Success: " + result);
}
};
$('input').unsigned_cloudinary_upload("discussionAdd", {
cloud_name: 'theCloudName',
tags: 'discussionAdd'
}, {
multiple: true
}).bind('cloudinarydone', function (e, data) {
$('.thumbnails').append($.cloudinary.image(data.result.public_id, {
format: 'jpg',
width: 150,
height: 100,
crop: 'thumb',
gravity: 'face',
effect: 'saturation:50'
}))
}
).bind('cloudinaryprogress', function (e, data) {
console.log("data loaded …Run Code Online (Sandbox Code Playgroud) 我正在尝试从 AWS 切换到 Cloudinary 来管理我网站上的图像。我在 Rails 应用程序上使用 Cloudinary 和 CarrierWave,并按照 Cloudinary 的指南设置图像上传和存储 ( http://cloudinary.com/documentation/rails_carrierwave )。当我尝试上传时出现此错误:
UsersController#update 中的 Cloudinary::CarrierWave::UploadError
签名无效(值已删除)。要签名的字符串 - 'public_id=(已删除值)sf×tamp=1433525724'。
这是我的用户控制器中的更新方法:
def update
@user = User.find(params[:id])
if @user.update_attributes(user_params)
flash[:notice] = "User information updated!"
redirect_to edit_user_registration_path
else
flash[:error] = "Error updating user information!"
redirect_to :back
end
end
def user_params
params.require(:user).permit(:name, :picture, :picture_cache)
end
Run Code Online (Sandbox Code Playgroud)
这是我的上传文件:
class PictureUploader < CarrierWave::Uploader::Base
include Cloudinary::CarrierWave
version :main do
process :resize_to_fill => [300, 350]
end
# def scale(width, height)
# # do something
# end
# …Run Code Online (Sandbox Code Playgroud) 我使用Cloudinary和Android应用程序.我使用以下方式上传图片:
cloudinary.uploader().upload(imagePath, ObjectUtils.emptyMap());
Run Code Online (Sandbox Code Playgroud)
问题是我需要url以后检索此图像.我可以使用任何方法将上传的图片网址存储在我的应用程序中吗?
谢谢!
我尝试了几种不同的方法,基本上我想从路由中取出cloudinary上传代码,并将其放入路由调用的函数中,以使代码更简洁。但是出于某种原因,我无法让异步/等待工作/等待上传完成才能完成。
这是我的路线示例:
var fieldsUpload = upload.fields([{ name: 'image1', maxCount: 1 }, { name: 'image2', maxCount: 1 }])
router.post('/upload', fieldsUpload, async function (req, res, next) {
var url1 = await uploadToCloudinary(req.files['image1'][0].path);
console.log("Cloudinary url: " + url1);
var url2 = await uploadToCloudinary(req.files['image2'][0].path);
console.log("Cloudinary url: " + url2);
res.send("Succesfull Upload");
});
Run Code Online (Sandbox Code Playgroud)
这是我的功能:
async function uploadToCloudinary(image) {
try{
let url = await cloudinary.v2.uploader.upload(image);
}
catch(err){ console.log(err)}
}
// function uploadToCloudinary(image) {
// cloudinary.v2.uploader.upload(image, function(error, result) {
// if(error) {
// console.log(error);
// }
// …Run Code Online (Sandbox Code Playgroud) 我使用带有cloudinary的react-player来自动播放和循环播放视频,无需控件(所以它看起来像一个gif)。
首选项当前设置为:
<ReactPlayer
url={elem.media_path}
playing={true}
loop={true}
controls={false}
/>
Run Code Online (Sandbox Code Playgroud)
视频在加载之前不会播放,除非控件已打开并且您手动启动它。
是否可以在没有控件的情况下自动启动视频?
我明白当使用以下语法直接上传到 Cloudinary 并将文件夹名称作为参数传递时,这是如何下降的。
Cloudinary::Uploader.upload("sample.jpg", :use_filename => true, :folder => "folder1/folder2")
Run Code Online (Sandbox Code Playgroud)
但是,我正在使用 ActiveStorage,当我以上述方式上传照片时,它不会附加到我的Post模型或以任何方式与我的应用程序关联。
我正在使用以下代码附加图像
post.send(:images).attach io: StringIO.new(new_data), filename: blob.filename.to_s,
content_type: 'image'
Run Code Online (Sandbox Code Playgroud)
它不接受指定文件夹的参数。我已尽力阅读 ActiveStorage 和 Cloudinary 文档,试图找到一种方法来完成这项工作,但是,我似乎无法弄清楚。
我已经看到设置自定义文件夹标头可能是使其工作的一种方法,但再次无法弄清楚如何为下面发生的上述代码设置自定义标头job。
require 'tmpdir'
require 'fileutils'
require 'open-uri'
class ResizeImagesJob < ApplicationJob
queue_as :default
def perform(post)
post.images.each do |image|
blob = image.blob
blob.open do |temp_file|
path = temp_file.path
pipeline = ImageProcessing::MiniMagick.source(path)
.resize_to_limit(1200, 1200)
.call(destination: path)
new_data = File.binread(path)
post.send(:images).attach io: StringIO.new(new_data), filename: blob.filename.to_s,
content_type: 'image'
end
image.purge_later
end
end
end
Run Code Online (Sandbox Code Playgroud)
上述工作正在做的是等到帖子创建后,然后调整照片大小并将照片重新附加到帖子以及删除原始照片。我采用这种方法是为了避免上传后直接在 Cloudinary …
jobs ruby-on-rails http-headers cloudinary rails-activestorage
我正在学习 Next JS,并且正在尝试将我的应用程序导出为静态站点。结果,我使用 Cloudinary 来处理图像,问题是它们没有显示。接下来的JS似乎在URL中添加了一些参数,这破坏了图像,下面是一个例子:
似乎路径中额外的f_auto,c_limit,w_384,q_auto打破了它。
这是因为我有一个免费的 Cloudinary 帐户吗?我该如何解决?
作为参考,这是我的next.config.js:
module.exports = {
basePath: '/out',
assetPrefix: '/out',
images: {
loader: 'cloudinary',
imageSizes: [16, 32, 48, 64, 96, 128, 256, 384],
path: 'https://res.cloudinary.com/dnliyglel/image/upload/v1624031405/next-tutorial/',
},
exportPathMap: async function() {
const paths = {
'/': { page: '/' },
'/posts/first-post': { page: '/posts/first-post'}
};
return paths;
}
};
Run Code Online (Sandbox Code Playgroud)
以下是如何将其添加到组件的示例:
<Image
priority
src="/images/profile_ileph2.jpg"
className={utilStyles.borderCircle}
height={144}
width={144}
alt={name}
/>
Run Code Online (Sandbox Code Playgroud) 嗨,我正在寻找一种使用 Node Js asyc 等待功能上传多个图像然后捕获到数组中的 API 服务器端上传解决方案。我按照这个 链接来实现我的代码。在控制台中,它显示了我期望的数组,但它没有给我任何响应。
这是我到目前为止尝试过的,
exports.upload_image = async(req, res) =>{
//let filePaths = req.files.path;
let multipleUpload = new Promise(async (resolve, reject) => {
let upload_len = req.files.length;
let upload_res = new Array();
for(let i = 0; i < upload_len; i++)
{
let filePath = req.files[i].path;
await cloudinary.v2.uploader.upload(filePath, { use_filename: true, unique_filename: false }, function (error, result) {
if(upload_res.length === upload_len)
{
/* resolve promise after upload is complete */
resolve(upload_res)
}
else if(result)
{
/*push …Run Code Online (Sandbox Code Playgroud) 在cloudinary中,我有一个名为images的文件夹,我想将文件上传到该文件夹中。我已经完成了 cloudinary 配置的设置。存储选项和文件过滤器已经完成。在请求中,我发送了将文件上传到 cloudinary 的 post 请求,但不上传到文件夹。如何将文件上传到 Cloudinary 中的某个文件夹?
const storage = multer.diskStorage({
destination: (req, file, cb) => {
cb(null, './images/');
},
filename: (req, file, cb) => {
cb(null, new Date().toISOString().replace(/:/g, '-') + file.originalname);
}
});
const fileFilter = (req, file, cb) => {
if (!file.mimetype.match(/jpe|jpeg|png|gif$i/)) {
cb(new Error('File is not supported'), false);
return;
}
cb(null, true);
};
const upload = multer({
storage,
fileFilter
});
router.post('/', upload.single('profileImage'), async (req,res) => {
const result = await cloudinary.v2.uploader.upload(req.file.path);
})
Run Code Online (Sandbox Code Playgroud) 文档非常令人沮丧。
我正在使用上传小部件来尝试允许用户为其个人资料上传多张图片。我不能使用未签名的上传,因为可能会被滥用。
我宁愿通过上传小部件而不是通过服务器上传文件,因为它看起来应该如此简单
我已经拼凑了我认为应该有效的内容,但它仍然说:Upload preset must be whitelisted for unsigned uploads
服务器:
// grab a current UNIX timestamp
const millisecondsToSeconds = 1000;
const timestamp = Math.round(Date.now() / millisecondsToSeconds);
// generate the signature using the current timestmap and any other desired Cloudinary params
const signature = cloudinaryV2.utils.api_sign_request({ timestamp }, CLOUDINARY_SECRET_KEY);
// craft a signature payload to send to the client (timestamp and signature required)
return signature;
Run Code Online (Sandbox Code Playgroud)
也尝试过
return {
signature,
timestamp,
};
Run Code Online (Sandbox Code Playgroud)
也尝试过
const signature = cloudinaryV2.utils.api_sign_request(
data.params_to_sign,
CLOUDINARY_SECRET_KEY,
); …Run Code Online (Sandbox Code Playgroud) cloudinary ×10
node.js ×4
javascript ×3
android ×1
api ×1
async-await ×1
file-upload ×1
http-headers ×1
jobs ×1
jquery ×1
meteor ×1
next.js ×1
react-player ×1
reactjs ×1
upload ×1