概述:
我正在使用 S3 让用户上传图片。
我正在使用new
方法进行更新,该方法将存储在#include<iostream>
using namespace std;
class node
{
public:
int data;
node *left,*right;
};
int main()
{
node *root=new node;
root=NULL;
cout<<"\nroot = "<<root; //This cout is executed since root has been initialized to NULL
std::cout.flush();
cout<<"\nroot->left = "<<root->left; //This line immediately throws segmentation fault
std::cout.flush();
return 0;
}
存储桶中的临时文件夹中的给定图像的URL删除,并将其删除到图像文件夹中。
这是我的上传对象:
root = 0
Segmentation fault (core dumped)
以及我正在使用的路由文件中:
PUT
问题:
此对象在上载新文件时有效,但不适用于更新 (重新命名文件)。
答案 0 :(得分:0)
问题在下面的行中:
key: function (request, file, cb) {
cb(null, folder + Date.now() + file.originalname);
}
Actually key是aws-s3中文件的名称/ ID。您要提供一个新密钥,因此s3将被标记为新文件。
您可以在此处根据所需名称更改逻辑,该名称应为字符串。
例如:
key: function (req, file, cb) {
console.log(file);
cb(null, `${Date.now().toString()}${file.originalname}`);
}
答案 1 :(得分:0)
可能不是为此您需要在存储矿山作品中传递的键对象
filename: function (req, file, cb) {
cb(null, file.fieldname + '-' + Date.now()+path.extname(file.originalname))
}