Google Storage nodejs上传MIME TYPE
如何为我正在上传的文件指定MIMEtypes。 我正在关注这个nodejs示例https://cloud.google.com/storage/docs/object-basics#storage-upload-object-nodejs
“`
function uploadFile (bucketName, fileName, callback) { // Instantiates a client const storageClient = Storage(); // References an existing bucket, eg "my-bucket" const bucket = storageClient.bucket(bucketName); // Uploads a local file to the bucket, eg "./local/path/to/file.txt" bucket.upload(fileName, (err, file) => { if (err) { callback(err); return; } console.log(`File ${file.name} uploaded.`); callback(); }); }
我总是得到默认
应用/八位字节stream
自己find答案。 您需要将这种types的元数据放入选项中。 在任何文档中找不到它。
function uploadFile (bucketName, fileName, callback) { // Instantiates a client const storageClient = Storage(); // References an existing bucket, eg "my-bucket" const bucket = storageClient.bucket(bucketName); // STARTING FROM HERE const options = { metadata: { contentType: 'image/jpeg', }, } // TO HERE // Uploads a local file to the bucket, eg "./local/path/to/file.txt" bucket.upload(fileName, options, (err, file) => { if (err) { callback(err); return; } console.log(`File ${file.name} uploaded.`); callback(); }); }
- Google云端存储似乎忽略了客户提供的encryption密钥标头
- 如何在Node.js中使用bigquery API获取800万条Google Cloudlogging?
- 不能过期使用node.js创build的Google云存储对象的SignedURL
- Google云端函数:无法validation请求
- 如何从服务器上的客户端JavaScript上载到Google云端存储?
- 如何访问谷歌云存储中的对象?
- 谷歌云存储对象删除谷歌API,Node.js和request.del()
- 通过GAE托pipe的node.js express服务器上传大文件
- 如何使用Node.js将base64编码图像(string)直接上传到Google Cloud Storage存储桶?