GeezerVison is showing github.com — CRC error when uploading a specific content to Google cloud storage · Issue #6386 · googleapis/google-cloud-java
CRC error when uploading a specific content to Google cloud storage #6386Labels 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. DescriptionThe 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 Activityathakor commented on Oct 10, 2019 @dk823832 I have tried it and able to reproduced.Contrary to your claim \r\n--__END_OF_PART__--\r\n01234, \r\n It's calling BufferedWriter.newLine() which uses the current platform's default line separator (unless you explicitly set the line.separator system property). On Unix systems this will be "\n" so you just add \n instead of \r\n error will gets disappear.
String s = String.format("\n--__END_OF_PART__--\n01234");
dk823832 commented on Oct 11, 2019 This is not about platform specific line separator. The issue is reproducible on Linux, see my second comment how to reproduce it. Storage API accepts a byte array so it shouldn't matter what content that array contains and it should be able to upload it. dk823832 commented on Oct 23, 2019 Any news on this issue? Another reproducer on Linux without using String.format:
replace String s = String.format("\n--END_OF_PART--\n01234");
with byte s[] = {13, 10, 45, 45, 95, 95, 69, 78, 68, 95, 79, 70, 95, 80, 65, 82, 84, 95, 95, 45, 45, 13, 10, 48, 49, 50, 51, 52};
and storage.create(blobInfo, s.getBytes());
with storage.create(blobInfo, s); added type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns. priority: p2Moderately-important priority. Fix may not be included in next release. and removed on Oct 23, 2019fazunenko commented on Dec 4, 2019
MetadataMetadataapi: 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. DevelopmentNo branches or pull requestsIssue actions
|