MCPcopy Index your code
hub / github.com/Bitmessage/PyBitmessage / saveFile

Function saveFile

src/bitmessagecli.py:603–635  ·  view source on GitHub ↗
(fileName, fileData)

Source from the content-addressed store, hash-verified

601 main()
602
603def saveFile(fileName, fileData): #Allows attachments and messages/broadcats to be saved
604
605 #This section finds all invalid characters and replaces them with ~
606 fileName = fileName.replace(" ", "")
607 fileName = fileName.replace("/", "~")
608 #fileName = fileName.replace("\\", "~") How do I get this to work...?
609 fileName = fileName.replace(":", "~")
610 fileName = fileName.replace("*", "~")
611 fileName = fileName.replace("?", "~")
612 fileName = fileName.replace('"', "~")
613 fileName = fileName.replace("<", "~")
614 fileName = fileName.replace(">", "~")
615 fileName = fileName.replace("|", "~")
616
617 directory = 'attachments'
618
619 if not os.path.exists(directory):
620 os.makedirs(directory)
621
622 filePath = directory +'/'+ fileName
623
624 ''&#x27;try: #Checks if file already exists
625 with open(filePath):
626 print 'File Already Exists'
627 return
628 except IOError: pass''&#x27;
629
630
631 f = open(filePath, 'wb+') #Begin saving to file
632 f.write(fileData.decode("base64"))
633 f.close
634
635 print '\n Successfully saved '+ filePath + '\n'
636
637def attachment(): #Allows users to attach a file to their message or broadcast
638 theAttachmentS = ''

Callers 3

readSentMsgFunction · 0.85
readMsgFunction · 0.85
UIFunction · 0.85

Calls 2

writeMethod · 0.45
decodeMethod · 0.45

Tested by

no test coverage detected