से Google क्लाउड के साथ उल्का के स्लिंगशॉट पैकेज का उपयोग करने में त्रुटि मैं प्रोफ़ाइल छवि अपलोड करने के लिए उपयोगकर्ता के लिए अपनी वेबसाइट पर एक छोटा अपलोड अनुभाग सेट अप करने का प्रयास कर रहा हूं। मेरे द्वारा Google क्लाउड साथ गुलेल का उपयोग कर रहा है और स्थानीय होस्ट से इस परीक्षण, लेकिन मैं इन त्रुटियों को मिलता है:स्थानीय क्लाउड
OPTIONS https://mybucket.storage.googleapis.com/ net::ERR_INSECURE_RESPONSE
मैं समझ इस त्रुटि मेरी CORS विन्यास की वजह से है, इसलिए मैं अलग के सभी प्रकार की कोशिश की सेटअप और कुछ भी काम करता है।
यह मेरी सबसे हाल CORS सेटअप है:
[
{
"origin": ["http://localhost:3000/"],
"responseHeader": ["Content-Type"],
"method": ["GET", "HEAD", "DELETE"],
"maxAgeSeconds": 3600
}
]
मैं भी इस तरह इसे करने की कोशिश:
[
{
"origin": ["*"],
"responseHeader": ["*"],
"method": ["GET", "HEAD", "DELETE"],
"maxAgeSeconds": 3600
}
]
फिर भी, कुछ भी नहीं। पहले की तरह ही त्रुटि।
if(Meteor.isServer){
// Initiate file upload restrictions
Slingshot.fileRestrictions("userLogoUpload", {
//Only images are allowed
allowedFileTypes: ["image/png", "image/jpeg", "image/gif"],
//Maximum file size:
maxSize: 2 * 1024 * 1024 // 2 MB (null for unlimited)
});
// Google Cloud Directives
Slingshot.createDirective("userLogoUpload", Slingshot.GoogleCloud, {
bucket: Meteor.settings.public.GoogleCloudBucket,
GoogleAccessId: Meteor.settings.private.GoogleAccessId,
GoogleSecretKey: Assets.getText("xxxxxxxxxx.pem"),
// Uploaded files are publicly readable
acl: "public-read",
authorize: function(){
if(!Meteor.userId()){
throw new Meteor.error("Login Required", "Please log in to upload files");
}
return true;
},
key: function(file){
let user = Meteor.users.findOne(Meteor.userId());
return user.profile.username + "/" + file.name;
}
});
}
यहाँ ग्राहक के पक्ष अपलोड दीक्षा है::
let uploader = new Slingshot.Upload("userLogoUpload");
uploader.send(document.getElementById("upload").files[0], function(error, downloadUrl){
if(!error){
console.log(downloadUrl);
} else{
console.error('Error uploading', uploader.xhr.response);
console.log(error);
}
सभी चर की जाँच
इस गुलेल के लिए अपने सर्वर कोड है। मेरी पेम फ़ाइल जांचती है और ठीक काम करती है। तो Google क्लाउड या जिस तरह से मैंने अपनी सीओआरएस फ़ाइल स्थापित की है, उसके साथ कोई त्रुटि होनी चाहिए।
किसी भी मदद की सराहना की जाएगी।
क्या आपने विधियों में पोस्ट जोड़ने का प्रयास किया था? जैसे 'विधि": ["प्राप्त करें", "हेड", "हटाएं", "पोस्ट"] ' – carlevans719
@ carlevans719 हां, मैंने पोस्ट विधि जोड़ा। यह तार्किक पहली बात थी जो मैंने किया था, लेकिन कुछ भी जुड़ा हुआ नहीं था। –
प्रतिक्रिया में त्रुटि को पूरी तरह से देखना चाहते हैं, अपवाद नहीं, लेकिन कुछ चीजें ध्यान में आती हैं: – Mussser