Guest User

Untitled

a guest
Nov 20th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. import inotify.adapters
  2. from minio import Minio
  3. from minio.error import ResponseError
  4.  
  5. minioClient = Minio('play.minio.io:9000',
  6. access_key='Q3AM3UQ867SPQQA43P2F',
  7. secret_key='zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG',
  8. secure=True)
  9.  
  10. def _main():
  11. i = inotify.adapters.Inotify()
  12.  
  13. i.add_watch(b'/tmp/1')
  14.  
  15. try:
  16. for event in i.event_gen():
  17. if event is not None:
  18. (header, type_names, watch_path, filename) = event
  19. if type_names[0] is 'IN_CLOSE_WRITE':
  20. print(minioClient.fput_object('testbucket', filename, watch_path+'/'+filename))
  21.  
  22. finally:
  23. i.remove_watch(b'/tmp/1')
  24.  
  25. if __name__ == '__main__':
  26. _main()
Add Comment
Please, Sign In to add comment