-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
send file object to state and read bianaries and hashes outside of re…
…act #2766
- Loading branch information
Josh Pollock
committed
Oct 25, 2018
1 parent
fb9ca9c
commit 200bfb7
Showing
13 changed files
with
6,984 additions
and
72 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,9 @@ | ||
export const getFieldConfigBy = (fieldConfigs, findBy, findWhere ) =>{ | ||
return fieldConfigs.find( field => findWhere ===field[findBy] ); | ||
|
||
} | ||
}; | ||
const CryptoJS = require("crypto-js"); | ||
|
||
export const hashFiles = (files) => { | ||
return files.map( file => CryptoJS.MD5(contents).toString() ); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?php | ||
if( file_exists(__DIR__ . '/screenshot.jpeg') ){ | ||
echo md5_file(__DIR__ . '/screenshot.jpeg'); | ||
} | ||
exit; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import {hashFiles} from "../../../render/util"; | ||
|
||
const CryptoJS = require("crypto-js"); | ||
|
||
var fs = require('fs'); | ||
//979296365572B262DBDA9C5186C7D0BE | ||
const expectHash = '979296365572b262dbda9c5186c7d0be'; | ||
|
||
describe( 'File hashing', () => { | ||
it( 'Has php-compatible md5 file function', () => { | ||
const contents = fs.readFileSync(__dirname + '/screenshot.jpeg'); | ||
const foundHash = CryptoJS.MD5(contents).toString(); | ||
expect(foundHash).toEqual(expectHash ); | ||
|
||
}); | ||
|
||
it( 'Function hashes array', () => { | ||
const hashes = hashFiles( [ | ||
fs.readFileSync(__dirname + '/screenshot.jpeg') | ||
]); | ||
expect( hashes[0] ).toBe( expectHash ); | ||
}) | ||
}) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters