Bild auf amazonS3 hochladen, Ausgabe Froala
Derzeit integriere ich froala in mein Projekt (das in angualarJs und laravel ist). Ich muss das Bild auf amazonS3 hochladen. Aber ich habe einige Probleme mit dem amazoneS3-Pfad. Hier ist mein Code.
mit im Blick,
Ich habe fileUploadToS3 in file.min.js auf true geändert ( gemäß den Dokumenten. )
mit im Winkelregler
Data.get('{{url}}').then(function(data){ var dta = angular.fromJson(data); $scope.sign = dta.sign; $scope.policy = dta.policy; $scope.bucket = dta.bucket; $scope.region = dta.region; $scope.keystart = dta.keystart; $scope.acl = dta.acl; $scope.accessKey= dta.key; $('#froala-sample-2').froalaEditor({ enter: $.FroalaEditor.ENTER_P, imageUploadToS3: { bucket: $scope.bucket, region: $scope.region, keyStart: $scope.keystart, params: { acl: $scope.acl, AWSAccessKeyId: $scope.accessKey, policy: $scope.policy, signature: $scope.sign, } } }) .on('froala.image.uploadedToS3', function (e, editor, link, key, response) { console.log ('S3 Link:', link); console.log ('S3 Key:', key); });}, function (error) {});
Hier erstelle ich die Signatur und die Richtlinie
public function createSignature() { // Set date timezone. date_default_timezone_set('Europe/Bucharest'); $bucket = '-bucket-'; $region = '-region-'; $keyStart = '-keystart-'; $acl = '-acl-'; $accessKeyId = $_SERVER['AWS_ACCESS_KEY']; $secret = $_SERVER['AWS_SECRET_ACCESS_KEY']; $policy = base64_encode( json_encode( array( 'expiration' => date('Ymd\TH:i:s.000\Z', strtotime('+1 day')), 'conditions' => array( array('bucket' => $bucket), array('acl' => $acl), array('success_action_status' => '201'), array('x-requested-with' => 'xhr'), array('starts-with', '$key', $keyStart), array('starts-with', '$Content-Type', '') // accept all files ) ))); $aData['policy'] = $policy; $aData['sign'] = base64_encode(hash_hmac('sha1', $policy, $secret, true)); $aData['bucket'] = $bucket; $aData['region'] = $region $aData['keystart'] = $keyStart; $aData['acl'] = $acl; $aData['key'] = $accessKeyId; return json_encode($aData);}
Wenn ich ein Bild hochlade, erhalte ich das folgende Problem: OPTIONS https://undefined.amazonaws.com/undefined net::ERR_NAME_NOT_RESOLVED. Sagt mir bitte jemand, wie ich dieses Problem lösen kann? Danke im Voraus.