我试图在我的项目中使用AWS Aurora Serverless for MySQL,但我无法连接到它,尽管我有端点,用户名和密码.
我做了什么:
Ressult:
用户'admin'从主机到服务器的连接尝试失败xxxxx.cluster-abcdefg1234.eu-west-1.rds.amazonaws.com:3306:无法连接到'xxxxx.cluster-abcdefg1234上的MySQL服务器. eu-west-1.rds.amazonaws.com'(60)
我做错了吗?请指教.
****编辑****
我尝试使用容量类型创建另一个Aurora数据库:Provisioned.我可以使用MySql workbench的用户名和密码无缝连接到端点.这意味着端口3306为工作台打开.
我使用AngularFire2从Firebase数据库中获取数据(实时).
我做了什么:
{"class":{"student":{"Tom":"male","Mary":"female","Peter":"male","Laura":"female"},"numberOfStudent":10} }
app.component.ts
import { AngularFireDatabase } from 'angularfire2/database';
import { Observable } from 'rxjs/Observable';
...
export class AppComponent {
class: Observable<any>;
students: Observable<any[]>;
constructor(private db: AngularFireDatabase) {
this.class = db.object(‘class’).valueChanges();
this.students = db.list(‘class/student’).snapshotChanges();
}
}
Run Code Online (Sandbox Code Playgroud)app.component.html:
<h2>Class size: {{ (class | async)?.numberOfStudent }}</h2>
<ul>
<li *ngFor="let i of students | async">
{{i.key}} : {{i.value}}
</li>
</ul>Run Code Online (Sandbox Code Playgroud)
发生了什么:
班级人数:10
汤姆:
玛丽 :
彼得:
劳拉:
它不返回list的值.
任何建议表示赞赏.
我试图在 S3 上以编程方式上传一个高达 1GB 的非常大的文件。因为我发现 AWS S3 支持大文件的分段上传,所以我找到了一些 Python 代码来做到这一点。(链接)
我的观点:上传速度太慢(将近1分钟)。
有什么办法可以提高分段上传的性能。或者任何支持 S3 上传的好的库
我用带有以下代码片段的标签创建了对象
PutObjectRequest putRequest = new PutObjectRequest(bucketName, keyName, new File(filePath));
List<Tag> tags = new ArrayList<Tag>();
tags.add(new Tag("Key1", "Value1"));
tags.add(new Tag("Key2", "Value2"));
putRequest.setTagging(new ObjectTagging(tags));
PutObjectResult putResult = s3client.putObject(putRequest);
Run Code Online (Sandbox Code Playgroud)
我得到带有代码的对象列表
s3client.listObjectsV2(params, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data);
}
Run Code Online (Sandbox Code Playgroud)
我的问题:
如何获取按标签过滤的对象列表?
如果无法按标签过滤,S3引入标签的目的是什么?
我正在使用无服务器在AWS上部署我的API。
在无服务器中,它允许部署一个功能:
sls deploy -f <function name>
Run Code Online (Sandbox Code Playgroud)
但是它不允许删除一个函数:
sls remove // will remove all functions.
Run Code Online (Sandbox Code Playgroud)
有什么方法可以删除不影响其他功能的单个功能?
我在 Python 中创建了一个 lambda(使用 Serverless),它将由 SQS 消息触发。
处理程序
s3 = boto3.resource('s3')
def process(event, context):
response = None
# for record in event['Records']:
record = event['Records'][0]
message = dict()
try:
message = json.loads(record['body'])
s3.meta.client.download_file(const.bucket_name, 'class/raw/photo/' + message['photo_name'], const.raw_filepath + message['photo_name'])
...
response = {
"statusCode": 200,
"body": json.dumps(event)
}
except Exception as ex:
error_msg = 'JOB_MSG: {}, EXCEPTION: {}'.format(message, ex)
logging.error(error_msg)
response = {
"statusCode": 500,
"body": json.dumps(ex)
}
return response
Run Code Online (Sandbox Code Playgroud)
常量文件
bucket_name = 'test'
raw_filepath = '/var/task/raw/'
Run Code Online (Sandbox Code Playgroud)
我创建了一个文件夹“raw”,与文件 handler.py 相同,然后部署无服务器 …
我正在尝试在单元格中实现"编辑"按钮.
到目前为止我做了什么:
MainController:
class MainController: UICollectionViewController, UICollectionViewDelegateFlowLayout {
let imgCellId = "imgCellId"
override func viewDidLoad() {
collectionView?.backgroundColor = .white
collectionView?.register(ImgItemCell.self, forCellWithReuseIdentifier: imgCellId)
}
override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: imgCellId, for: indexPath) as! ImgItemCell
cell.editButton.addTarget(self, action: #selector(buttonPressed), for: .touchUpInside)
return cell
}
func buttonPressed(){
print("buttonPressed !")
}
}
Run Code Online (Sandbox Code Playgroud)
ImgItemCell:
import Material
class ImgItemCell: UICollectionViewCell{
override init(frame: CGRect){
super.init(frame: frame)
setupViews()
}
...
let editButton: RaisedButton = {
let button = …Run Code Online (Sandbox Code Playgroud) 我正在构建一个电子邮件发送服务(lambda,Nodejs),该服务将同时将电子邮件发送到地址列表。
由于要求:每个地址接收不同的电子邮件内容,我不能在一个请求中发送多个电子邮件,而是一个一个地发送。
_array = ... // list of address + html content, > 10000 records
for (var i = 0; i < _array.length; i++) {
var params = {
Destination: {/* required */
ToAddresses: [_array[i].email]
},
Message: {/* required */
Body: { /* required */
Html: {
Data: _array[i].html,
Charset: 'UTF-8'
},
},
Subject: { /* required */
Data: 'Your order detail', /* required */
Charset: 'UTF-8'
}
},
Source: "mytestemail@email.com"
}
let send = await ses.sendEmail(params).promise();
}
Run Code Online (Sandbox Code Playgroud)
目前,我没有要测试的大数据,但是我测试了100-200封电子邮件,它可以正常工作,并且需要15-40秒才能完成发送电子邮件。从数学上来说,10000需要25分钟以上才能完成任务。因此,此方法不可扩展,因为15分钟的lambda超时限制
任何更好的方法或建议,表示赞赏。 …
I have 2 arrays as below:
array 1:
[
{"name": "A", "class" : "1"},
{"name": "B", "class" : "2"},
{"name": "C", "class" : "3"}
]
Run Code Online (Sandbox Code Playgroud)
array 2:
[ "A","B"]
Run Code Online (Sandbox Code Playgroud)
I wanna merge 2 arrays, and my expected result:
[
{"name": "A", "class" : "1"},
{"name": "B", "class" : "2"}
]
Run Code Online (Sandbox Code Playgroud)
Any suggestion is appreciated
What I found so far:
我有一个物联网项目,它是:
我采用了 2 种不同的方式
圆周率:
class CallbackContainer(object):
def __init__(self, client):
self._client = client
def messagePrint(self, client, userdata, message):
print("Received a new message: ")
print(message.payload)
print("from topic: ")
print(message.topic)
print("--------------\n\n")
myAWSIoTMQTTClient = AWSIoTMQTTClient("myClientID")
myAWSIoTMQTTClient.configureEndpoint("xxxxx.iot.eu-west-1.amazonaws.com", 8883)
myAWSIoTMQTTClient.configureCredentials("./certs/rootCA.pem", "./certs/xxxxxxx-private.pem.key", "./certs/xxxxxxx-certificate.pem.crt")
myAWSIoTMQTTClient.configureConnectDisconnectTimeout(10) # 10 sec
myAWSIoTMQTTClient.configureMQTTOperationTimeout(5) # 5 sec
myCallbackContainer = CallbackContainer(myAWSIoTMQTTClient)
myAWSIoTMQTTClient.connect()
myAWSIoTMQTTClient.subscribe("topic_both", 0, myCallbackContainer.messagePrint)
myAWSIoTMQTTClient.subscribe("topic_bulb1", 0, myCallbackContainer.messagePrint)
while True:
time.sleep(1)
Run Code Online (Sandbox Code Playgroud)Javascript:
var params = {
payload: …Run Code Online (Sandbox Code Playgroud)python ×4
amazon-s3 ×2
aws-lambda ×2
boto3 ×2
javascript ×2
node.js ×2
serverless ×2
amazon-ses ×1
angular ×1
angularfire2 ×1
arrays ×1
aws-iot ×1
aws-sdk ×1
firebase ×1
ios ×1
iot ×1
json ×1
mysql ×1
python-3.x ×1
swift ×1
tags ×1
upload ×1