Skip to content

CRC error when uploading a specific content to Google cloud storage #6386

@dk823832

Description

@dk823832

The following code results in error message Provided CRC32C "..." doesn't match calculated CRC32C "...":

Storage storage;
String bucketName = "bucket";
String blobName = "gtest";
String GOOGLE_CREDENTIALS_SCOPE = "https://www.googleapis.com/auth/cloud-platform";
String APPLICATION_TYPE = "application/octet-stream";
String googleCredentialsJson = null;

ArrayList al = new ArrayList();
al.add(GOOGLE_CREDENTIALS_SCOPE);
String s = String.format("\r\n--__END_OF_PART__--\r\n01234");

googleCredentialsJson = new String ( Files.readAllBytes( Paths.get("google.json") ) );
GoogleCredentials credentials = GoogleCredentials.fromStream(new ByteArrayInputStream(googleCredentialsJson.getBytes()))
                .createScoped(al);
storage = StorageOptions.newBuilder().setCredentials(credentials).build().getService();

BlobId blobId = BlobId.of(bucketName, blobName);
BlobInfo blobInfo = BlobInfo.newBuilder(blobId).setContentType(APPLICATION_TYPE).build();

storage.create(blobInfo, s.getBytes());

The issue is reproducible using example programs on Linux:
printf "\r\n--END_OF_PART--\r\n01234\n" > rr
java -jar ... com.google.cloud.examples.storage.StorageExample upload rr bucket

Metadata

Metadata

Assignees

Labels

api: storageIssues related to the Cloud Storage API.priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions