Difference between revisions of "TruxtonChildFileIO"

From truxwiki.com
Jump to navigation Jump to search
Line 31: Line 31:
 
The following methods are also present to make tasks of adding items extracted from a file easier.
 
The following methods are also present to make tasks of adding items extracted from a file easier.
  
* [[TruxtonFileIO_newartifact | newartifact()]]
+
* [[TruxtonChildFileIO_newartifact | newartifact()]]
* [[TruxtonFileIO_newchild | newchild()]]
+
* [[TruxtonChildFileIO_newchild | newchild()]]
* [[TruxtonFileIO_newevent | newevent()]]
+
* [[TruxtonChildFileIO_newevent | newevent()]]
* [[TruxtonFileIO_newexif | newexif()]]
+
* [[TruxtonChildFileIO_newexif | newexif()]]
* [[TruxtonFileIO_newlocation | newlocation()]]
+
* [[TruxtonChildFileIO_newlocation | newlocation()]]
* [[TruxtonFileIO_newrelation | newrelation()]]
+
* [[TruxtonChildFileIO_newrelation | newrelation()]]
* [[TruxtonFileIO_newurl | newurl()]]
+
* [[TruxtonChildFileIO_newurl | newurl()]]
* [[TruxtonFileIO_newusb | newusb()]]
+
* [[TruxtonChildFileIO_newusb | newusb()]]
 
+
* [[TruxtonChildFileIO tag | tag()]]
  
 
=Sample=
 
=Sample=

Revision as of 14:37, 25 May 2020

This class provides a writable file to add to Truxton.

IOBase Methods

From IOBase it implements:

RawIOBase Methods

From RawIOBase it implements:

Truxton Methods

The above methods will let you read from a file in Truxton as if it were any other file in Python. The following methods are also present to make tasks of adding items extracted from a file easier.

Sample

This will retrieve a file from Truxton, print the name and hash as stored in the database then calculate a hash on the contents and print that.

import truxton
import shutil
from pathlib import Path

def add_file(parent_truxton_file, filename):
  source_file = open(filename, "rb")
  child = parent_truxton_file.newchild()
  child.name = Path(filename).name
  shutil.copyfileobj(source_file, child)
  source_file.close()
  child.save()
  return child

def main():
  t = truxton.create()
  file = t.getfileid("5ec2a123-74d6-5da7-0653-4e6800000000")
  child = add_file(file, "C:\decrypts\PlainText.txt")

if __name__ == "__main__":
  main()