s3.putObject({
Bucket: bucketName,
Key: fileName,
Body: file,
ACL: 'bucket-owner-full-control'
}, function(err, data) {
if (err) {
console.log(err);
}
console.log(data)
});
Run Code Online (Sandbox Code Playgroud)
我使用此代码将图像上传到服务器amazon s3.但我无法上传相同的名称文件(此名称已存在于服务器s3上).如何上传相同的名称文件,并覆盖服务器s3上存在的文件.谢谢你的帮助 :)
我在Html文件中有这个代码.
<input #fileInput type="file" />
Run Code Online (Sandbox Code Playgroud)
demo.ts
import {
Component,
Inject,
OnInit,
ElementRef,
Renderer,
ViewQuery
} from '@angular/core';
@Component({
selector: 'demo',
templateUrl: 'client/dev/demo/demo.html',
})
export class DemoComponent implements OnInit{
@ViewQuery('fileInput') fileInput:ElementRef;
constructor(){}
triggerFile(){
// do something
// trigger input type="file" here
this.fileInput.nativeElement.click();
}
ngOnInit() {
}
}
Run Code Online (Sandbox Code Playgroud)
我看到这个答案:如何从角度2的按钮点击触发输入文件的点击事件? 当然有效.但我想在triggerFile()函数中触发input type ="file",我使用ViewQuery和nativeElement.click()函数.但它控制此错误"无法读取未定义的属性'nativeElement'".我使用angular2 Rc 1.谢天谢地