Question

How I obtain the file bytes from bundle inputData?

  • 22 May 2023
  • 3 replies
  • 183 views

I have a file as input and I can't get the bytes, when I zap for example with a file from Google Drive I get this as input:

hydrate eJx1jk9zgjAU×L_LOzMd_mmLMzOEoUwtINGxY-XC×BA1gYQKAYu0373B2mP3ULu_f

e8CpJKKSpWp_ovCBBAYWGSjsCQOYZIMHM_1bHP8AABpG1WJtqH1LbAsZzQau54BmJCa^RN_ rqNIwI7RMs8kFsNsTrtsx0qg14sTrvcNTC5wP3n3BVWHSi_Aoc9rrkg6edBvNIdQYFa- tJloVk nd2

7Yy14Dm6ZC8DghCSYGCD3u-XigpD614PePJGan3YG-nU30UilUdr81-4RsnORM75UU_R36Ebv

L3vdik8yXGi-P358YVVFBB75-CulumZvm07ZZY2hTPrI76_JcJE4T-y8PoaL4tdekZrtfrD1kpc6s:1 q14Ki:h48rk3iHmPQcT7ca4TORPbELNVM|||hydrate

And of course, when I get the bytes it is not what I expect since they are not the same bytes of the original fileI get the input via bundle.inputData.new_data, this is my code:

const publishData = (z, bundle) => {
    ...
     const data = bundle.inputData.new_data;
     ...
     function publish(record, publisher, host) {...}

  
}
module.exports = {
...
     operation: {
         inputFields: [
             {key: "methods", label: "Method", choices: {hosted: 'Hosted', ipfs: 'IPFS'}, required: true},
             {key: "new_data", label: "Data", required: false}
         ],
         perform: publishData,
         sample: sample
     },
};


Do I need to dehydrate it to work whit the bytes?


Thank you


This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

3 replies

That’s not a big deal @renegonzalez 

I am a Developer with a 6 Years Experience in this bytes from bundle inputData!

Well Wishes!

 To obtain the file bytes from the bundle's inputData in Android, you can follow these steps:

Retrieve the inputData from the bundle using the appropriate key. For example, if you stored the file in the bundle with the key "fileData", you can retrieve it like this:

byte[] fileBytes = bundle.getByteArray("fileData");

Once you have the byte array, you can use it as needed. For example, if you want to write the bytes to a file, you can do so using FileOutputStream:

FileOutputStream outputStream = new FileOutputStream("path/to/output/file");
outputStream.write(fileBytes);
outputStream.close();

Alternatively, if you want to work with the bytes directly in memory, you can manipulate the byte array as required.



@johnbracket THanks Man!

For solving the issue with this code i have fix my website’s issue. If You wanna visit my blog so go it on this link https://www.pikashowhd.com/!

Thanks Again for putting me in!

 To obtain the file bytes from the bundle's inputData in Android, you can follow these steps:

Retrieve the inputData from the bundle using the appropriate key. For example, if you stored the file in the bundle with the key "fileData", you can retrieve it like this:

byte[] fileBytes = bundle.getByteArray("fileData");

Once you have the byte array, you can use it as needed. For example, if you want to write the bytes to a file, you can do so using FileOutputStream:

FileOutputStream outputStream = new FileOutputStream("path/to/output/file");
outputStream.write(fileBytes);
outputStream.close();

Alternatively, if you want to work with the bytes directly in memory, you can manipulate the byte array as required.