locked
Copying and hashing files

    Question

  • I wonder what is more battery friendly and ultimativly more performant:

    1. Copy a file and hash it then

    return FileIO.readBufferAsync(sourceFile).then(function(buffer) {
                var hash, hashData;
                hashData = hashAlgo.hashData(buffer);
                hash = CryptographicBuffer.encodeToHexString(hashData);
                return sourceFile.copyAsync(folder, "" + hash + sourceFile.fileType + "-tagging", NameCollisionOption.replaceExisting).then(function(blobFile) {

    I consider this variant less performant than the following, because the file is essentially read twice. Or are there any optimizations in place that a copyAsync is performing differently than a readBufferAsync + writeBufferAsync?

    Also I have the problem, that  FileIO.readBufferAsync fails to load very large files (tried with 3.3 GB iso image). Is there a reason for that?

    2. Read a file, build the hash from the buffer and write the buffer to disk


    Monday, June 04, 2012 12:20 PM

Answers

All replies