Beispiel #1
0
 def test_download(self):
     from osbot_utils.utils.Http import GET
     #print(GET('https://srv-file4.gofile.io/download/ePB3QX/aa-some-text.txt'))
     bytes = GET(
         'https://srv-file7.gofile.io/download/UL8zkd/JS_Siemens-original.pdf',
         encoding=None)
     print(Files.save_bytes_as_file(bytes, '/tmp/temp-2.pdf'))
 def test_file_protect(self):
     gw_azure = GW_Rebuild_Azure()
     target = '/Users/diniscruz//Downloads/bug.png'
     target = '/Users/diniscruz/Downloads/test/shake.jpeg'
     #target = '/Users/diniscruz/Downloads/aa-some-text.txt' # doesn't work
     bytes = gw_azure.file_protect(target)
     rebuilt = Files.save_bytes_as_file(bytes, extension='.txt')
     print('-------')
     print(rebuilt)
 def rebuild_files(targets):
     gw_azure = GW_Rebuild_Azure()
     rebuilds = []
     for file_name, content_type, file_path in targets:
         print(f'\n########## Rebuilding file: {file_name}')
         bytes = gw_azure.file_protect(file_path)
         if len(bytes) > 0:
             rebuilt_file = Files.save_bytes_as_file(bytes)
             print(f'########## File rebuild ok\n\n')
             rebuilds.append((file_name, content_type, rebuilt_file))
         else:
             print(f'########## File NOT rebuilt, using original \n')
             rebuilds.append((file_name, content_type, file_path))
     return rebuilds