0

I'm working on an issue where I've to pass some data from one spring boot application to another. The data size can range between 10-100MB. I get this byte array data from GCP blob storage as

public byte[] downloadFileFromGCS(String objectName, String bucketName) throws IOException {
    val storage = StorageOptions.getDefaultInstance().getService();
    val blob = storage.get(BlobId.of(bucketName, objectName));
    return blob.getContent();
}

The problem I'm facing is that I've to send it to different spring boot application for some processing, I've tried many different approaches like:

  • encoding into base64: which is not working because of huge size of byte files) by sending as Content-type:application/json
  • sending directly as byte array (not working because teh byte array values get changed/data loss)

Can someone suggest me what should I do in order to achieve this or any different approach like not sending byte[] array directly but using something different.

  • I would change the API of the service that is doing the processing so that you can send it the specification of where to get the data, rather than the data itself. – tgdavies Aug 09 '22 at 12:30
  • @tgdavies yes you are correct but actually, these are 2 different microservice with their specific role and I've to go with that way. Can you suggest something different? – Swarnim Pratap Singh Aug 09 '22 at 12:43
  • Your question is quite unclear, what kind of data are we talking about? Are you trying to pass java objects to a different application? This sounds like an x y problem to me where your actual question is "how do I (de)serialize java objects", which has nothing to do with cloud storage or spring. It's impossible to say what serialization format is sensible since you don't provide any info on the data, so I'd advise to start with json, by using jackson (which is included in spring boot afaik). There are millions of articles on using jackson. – somethingsomething Aug 09 '22 at 15:01
  • Whoever wrote the receiving service has presumably specified in which format and content type the data is to be transferred, and which HTTP verb to use. – tgdavies Aug 09 '22 at 21:56
  • Hopefully application/octet-stream, but you will have to find out. You can look at the accepts header of requests you make to the service. – tgdavies Aug 09 '22 at 21:58

0 Answers0