GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

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 #6386

New issue
Copy link
New issue
Copy link
Closed
googleapis/google-http-java-client
#916
googleapis/google-http-java-client#916
Closed
CRC error when uploading a specific content to Google cloud storage#6386
googleapis/google-http-java-client
#916
Copy link
Assignees
athakor
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.

Description

@dk823832
dk823832
opened on Oct 1, 2019
Issue body actions

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

Activity

  1. athakor
    added
    api: storageIssues related to the Cloud Storage API.
    type: questionRequest for information or clarification. Not an issue.
    on Oct 1, 2019
  2. athakor
    self-assigned this
    on Oct 10, 2019
  3. athakor commented on Oct 10, 2019

    @athakor
    athakor
    on Oct 10, 2019
    Contributor
    More actions

    @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");

  4. dk823832 commented on Oct 11, 2019

    @dk823832
    dk823832
    on Oct 11, 2019
    Author
    More actions

    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.

  5. dk823832 commented on Oct 23, 2019

    @dk823832
    dk823832
    on Oct 23, 2019
    Author
    More actions

    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);

  6. athakor
    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
    type: questionRequest for information or clarification. Not an issue.
    on Oct 23, 2019
  7. fazunenko commented on Dec 4, 2019

    @fazunenko
    fazunenko
    on Dec 4, 2019
    More actions

    The problem appears only if the given content includes "--__END_OF_PART__--" string which is used as a part delimiter by com.google.api.client.http.MultipartContent.java
    (https://github.com/googleapis/google-http-java-client/blob/master/google-http-client/src/main/java/com/google/api/client/http/MultipartContent.java)

    Such content being sent is recognized by the server side as multiple parts and handled in a different way: CRC32C/MD5 calculated only for the first part.

    If the content includes "--__END_OF_PART__" (without two dashes at the end) the server will reject:
    Caused by: com.google.api.client.googleapis.json.GoogleJsonResponseException: 400 Bad Request
    Malformed multipart body.

  8. chingor13
    closed this as completedin google-http-java-client#916on Dec 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @athakor
    athakor

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

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.