Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-cloud-platform/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google cloud platform 正在寻找使用谷歌云功能获取文件信息。_Google Cloud Platform_Google Cloud Storage_Google Cloud Functions - Fatal编程技术网

Google cloud platform 正在寻找使用谷歌云功能获取文件信息。

Google cloud platform 正在寻找使用谷歌云功能获取文件信息。,google-cloud-platform,google-cloud-storage,google-cloud-functions,Google Cloud Platform,Google Cloud Storage,Google Cloud Functions,我正在尝试收集一些我正在接收的文件的数据,我正在查找文件大小、记录数、文件接收日期。这些是.CSV文件。在这一点上,我有一个功能,将采取一个文件,土地在桶和拿起这个文件,并将其移动到一个新的桶。我假设有一些命令可以从我已经获取的文件中获取元数据。最终,我希望每次文件到达时都将这些结果写入文件、表或电子邮件中 注:这是我的第一个谷歌云项目,我绝对没有Java编码背景。以下是我目前掌握的代码: 任何建议都将不胜感激 exports.CopySomewhereElse = (event, callba

我正在尝试收集一些我正在接收的文件的数据,我正在查找文件大小、记录数、文件接收日期。这些是.CSV文件。在这一点上,我有一个功能,将采取一个文件,土地在桶和拿起这个文件,并将其移动到一个新的桶。我假设有一些命令可以从我已经获取的文件中获取元数据。最终,我希望每次文件到达时都将这些结果写入文件、表或电子邮件中

注:这是我的第一个谷歌云项目,我绝对没有Java编码背景。以下是我目前掌握的代码:

任何建议都将不胜感激

exports.CopySomewhereElse = (event, callback) => {
  const file = event.data;
  const context = event.context;

const Storage = require('@google-cloud/storage');

 // Creates a client
  const storage = new Storage();

  const srcBucketName = file.bucket;
  const srcFilename = file.name;
  const destBucketName = 'somewhere_else';
  const destFilename = file.name;

  // Copies the file to the other bucket
 storage
    .bucket(srcBucketName)
    .file(srcFilename)
    .copy(storage.bucket(destBucketName).file(destFilename))
    .then(() => {
      console.log(
        `gs://${srcBucketName}/${srcFilename} copied to gs://${destBucketName}/${destFilename}.`
      );
    })
    .catch(err => {
       console.error('ERROR:', err);
    });

  callback();
};

我能够找到解决方案:

它与File.size和File.TimeCreated一样简单

exports.CopySomewhereElse = (event, callback) => {
  const file = event.data;
  const context = event.context;

  const Storage = require('@google-cloud/storage');

  // Creates a client
  const storage = new Storage();

  const srcBucketName = file.bucket;
  const srcFilename = file.name;
  const destBucketName = 'somewhere_else';

  const destFilename = file.name;
  const filesize = file.size;
  const FileName = file.name;
  const FiletimeModified = file.LastModified;
  const FileID = file.ID;
  const FiletimeCreated = file.timeCreated


  //const fileContentDisposition = file.contentDisposition;



  // Copies the file to the other bucket
  storage
    .bucket(srcBucketName)
    .file(srcFilename)
    .copy(storage.bucket(destBucketName).file(destFilename))
    .then(() => {
      console.log
                (
                    `gs://${srcBucketName}/${srcFilename} copied to gs://${destBucketName}/${destFilename}.|${filesize}|${FileName}|${FiletimeCreated}|${srcBucketName}`
                )
            //  (
            //      `${filesize}`
            //  )
    ;
    })
    .catch(err => {
      console.error('ERROR:', err);
    });

  callback();
};

我想我找到了一个NPM软件包,它可以满足我的需要。。它位于以下站点:我能够安装该软件包。。。但我不知道如何测试或使用它…很抱歉对不同的问题发表评论(使用sendgrid和谷歌云平台发送电子邮件)这里-不想被以下消息曝光太多-我正处于产品的私人测试版中-如果感兴趣-通过LinkedIn与我联系您还可以查看的官方文档,具体来说,您可以在中找到可用元数据的信息。此外,只要您能够(通常在您最初发布问题后2天),请接受您自己的答案,以便社区确认此问题已解决。谢谢!