12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- public static int main(string[] args) {
- Ppub.CollectionServerRecord.resolve_records("libpeer.pcthingz.com");
- var creds = new Ppub.CollectionMemberCredentials.from_string("PYuKgL7SdQYc2Kf6UGG9pCE58m27qrYnCaM45cnxs64=:JbJ6OoNn2KcGX+Tk5C/hotGZCoHOkTNbadUrlk6aCRs=:tL+557eP7kE6ObAW0b5RjvYyU8Dl3oVTOvYA7LAwSdI9i4qAvtJ1BhzYp/pQYb2kITnybbuqticJozjlyfGzrg==:AJbFO6n/cOuD7kk+wu7DmQ58w6z0G3HsukVmIzxGaUM=");
- var collection_id = new Invercargill.BinaryData.from_base64("y8ibw54A93LDBKbgWm1EJ/WlbOkGX60DK+qp2lBHpjk=");
-
- var upload_file = File.new_for_path(args[1]);
- var file_size = upload_file.query_info("*", FileQueryInfoFlags.NONE).get_size();
- var client = new Pprf.HttpPprfClient("http://localhost:8080/test.php");
- var file_name = upload_file.get_basename();
-
- var collection = client.get_collection(collection_id);
- var member = Pprf.MemberIdentity.get_usable_identities(Invercargill.single(creds), collection).first_or_default();
- if(member == null) {
- print("No usable identity\n");
- return -2;
- }
- print(@"Acting as $(member.name)\n");
- print("Regisering name\n");
- var exists = false;
- try {
- client.register_name(collection_id, file_name, member);
- }
- catch(Pprf.Messages.PprfFailureError.NAME_EXISTS e) {
- print("Name already exists, will overwrite\n");
- exists = true;
- }
- print("Beginning upload\n");
- var file_stream = upload_file.read();
- var flags = exists ? Pprf.Messages.FinaliseUploadFlags.OVERWRITE_DESTINATION : 0;
- client.upload(collection_id, file_stream, file_size, file_name, exists, member, null, flags);
- print("Computing publication signature\n");
- var digest = Pprf.Util.file_checksum(upload_file);
- var publication = new Ppub.CollectionPublication(file_name, new DateTime.now_local(), member.name, creds, digest);
- print("Publishing publication\n");
- client.publish(collection_id, publication, member);
-
- print("Done\n");
- return 0;
- }
|