Google bigquery 从谷歌云存储下载文件随机损坏

Google bigquery 从谷歌云存储下载文件随机损坏,google-bigquery,google-cloud-storage,Google Bigquery,Google Cloud Storage,我正试图通过谷歌云存储下载Bigquery数据。我能够从BigQuery向GCS发送数据,但从GCS下载数据以加载文件时,数据会随机损坏 getObject.getMediaHttpDownloader().setDirectDownloadEnabled(true); out = fs.create(pathDir, true); getObject.executeMediaAndDownloadTo(out); boo

我正试图通过谷歌云存储下载Bigquery数据。我能够从BigQuery向GCS发送数据,但从GCS下载数据以加载文件时,数据会随机损坏

getObject.getMediaHttpDownloader().setDirectDownloadEnabled(true);
    out = fs.create(pathDir, true);                 
        getObject.executeMediaAndDownloadTo(out);
        boolean match= ismd5HashValid(o.getMd5Hash(), pathDir);
和检查md5校验和

private boolean ismd5HashValid(String md5hash, String path) {
        org.apache.hadoop.fs.Path pathDir = new org.apache.hadoop.fs.Path(path);
        org.apache.hadoop.conf.Configuration conf = new org.apache.hadoop.conf.Configuration();
        InputStream is = null;
        try {
            FileSystem fs = FileSystem.get(conf);
            MessageDigest md = MessageDigest.getInstance("MD5");
             is = fs.open(pathDir);
            byte[] bytes = new byte[1024];
            int numBytes;
            while ((numBytes = is.read(bytes)) != -1) {
                md.update(bytes, 0, numBytes);
            }
            byte[] digest = md.digest();
            String result = new String(Base64.encodeBase64(digest));
            Log.info("Source file md5hash {} Downloaded file md5hash {}", md5hash, result);         
            if (md5hash.equals(result)) {
                Log.info("md5hash check is valid");
                return true;
            }
        } catch (IOException e) {
            // TODO Auto-generated catch block
            Log.warn(e.getMessage(), e);
        } catch (NoSuchAlgorithmException e) {
            // TODO Auto-generated catch block
            Log.warn(e.getMessage(), e);
        } finally {
            IOUtils.closeQuietly(is);
        }
    return false;
    }

有几个问题:首先,如果您通过gsutil或googlecloudconsole下载该文件,您会得到预期的MD5吗?第二:是gzip文件吗?@Brandon 1。文件的MD5值与下载的文件不匹配。示例-源文件md5hash 8gmCoZuvcKlQSf83SUO0JQ==下载的文件md5hash iZnNF2ICJn9NmUKxNlxtHg==2。是的,它是一个gzip文件。有趣!gzip文件是否只包含一个文件?解压内容的MD5匹配吗?@brandon它是一个单独的Gzip文件。该文件已损坏,因此我无法打开它以检查md5值。