最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

node.js - Google Cloud Storage SDK (Nodejs) - Uncaught Exception: ApiError: Not Found" - Stack Overflow

programmeradmin1浏览0评论

I'm getting the error "Uncaught Exception: ApiError: Not Found" with google cloud storage sdk whenever I use createWriteStream (I'm using nodejs/typescript).

Initially in my code I was setting the bucket as ${anization}/${fileName}. But, then I saw in the logs the url google was trying to use to make the request, /{anizationId}/orders.csv/o/{anizationId}%2Forders.csv?alt=media (I'm omitting the actual anization id). It appears that's not using the bucket but just duplicating the fileName. So, I set the filename to orders.csv in case it was the / I had in there, and it's still generating the exact same request.

When I output the name and bucket of the file object before calling createWriteStream they're both showing the correct values as well.

  
const bucketName = 'shadowscore-data-import-production';
const bucket = this.storage.bucket(bucketName);

const newFilePath = 'orders.csv';
const newFile = bucket.file(newFilePath);
            
const writeStream = newFile.createWriteStream({ 
     resumable: false,
});
        
return new Promise((resolve, reject) => {
   stream.on('error', (error) => {
       writeStream.destroy(error);
       reject(error);
   });
        
   writeStream.on('error', (error) => {
       stream.unpipe();
       reject(error);
   });
        
   writeStream.on('finish', () => resolve(newFilePath));
        
   stream.pipe(writeStream);
});
发布评论

评论列表(0)

  1. 暂无评论