tonistiigi / mega

THIS REPO IS NOT MAINTAINED. Unofficial Node.js SDK for Mega
http://tonistiigi.github.com/mega
117 stars 33 forks source link

No way to delete file example storage.delete. #16

Closed manvir-singh closed 10 years ago

manvir-singh commented 10 years ago

You can only delete a file that you downloaded from mega.co.nz by using file.delete but you can't delete a file on mega.co.nz that is on the site. You can't delete it, you can upload using storage.Upload but

manvir-singh commented 10 years ago

You can't delete that file after uploading it there is nothing like storage.delete Is something like that going to be added?

tonistiigi commented 10 years ago

All files under your account are available under storage.files object or storage.mounts array. These are the same File objects with all the same methods. No pre-downloading is needed.

There is even an example for this:

# First run
node example/list <user> <pw>
# Pick one of the node ID-s (inside parenthesis)
node example/delete <user> <pw> <nodeID>
manvir-singh commented 10 years ago

Oh okay sorry for disturbing you, didn't see that. Thanks

manvir-singh commented 10 years ago

one last thing how do I get the "nodeId" of a file without knowing it. The only info I have on the file is size and the name of the file. So something like this. Console.log(storage.files["filename.txt"].nodeId);

tonistiigi commented 10 years ago
var ids = Object.keys(storage.files).filter(function(f) { return f.name === 'filename.txt'})
manvir-singh commented 10 years ago

thanks so much =) would you like to be given credit in my application?

manvir-singh commented 10 years ago

var ids = Object.keys(storage.files).filter(function(f) { return f.name === 'delete.js'}); the code above returns "[]" ? no ids are returned?

fyi Object.keys(storage.files) returns the nodeId but i don't know which one goes with which file.

output of storage.files: { IIVC0aqC: { downloadId: undefined, key: undefined, api: { keepalive: false, counterId: 1908482752, sid: '5r4fUf4IxvRsBJl6TBdHjEJJWUgtX1RQNExZEYBFy1BFBsWIP5V3Jbapig', _events: [Object] }, nodeId: 'IIVC0aqC', timestamp: 1361048675, type: 3, directory: true, name: 'Inbox' }, IYNgURCC: { downloadId: undefined, key: undefined, api: { keepalive: false, counterId: 1908482752, sid: '5r4fUf4IxvRsBJl6TBdHjEJJWUgtX1RQNExZEYBFy1BFBsWIP5V3Jbapig', _events: [Object] }, nodeId: 'IYNgURCC', timestamp: 1361048675, type: 4, directory: true, name: 'Rubbish Bin' }, Ud1Q0bCL: { downloadId: undefined, key: undefined, api: { keepalive: false, counterId: 1908482752, sid: '5r4fUf4IxvRsBJl6TBdHjEJJWUgtX1RQNExZEYBFy1BFBsWIP5V3Jbapig', _events: [Object] }, nodeId: 'Ud1Q0bCL', timestamp: 1361048675, type: 2, directory: true, name: 'Cloud Drive', children: [ [Object] ] }, UV12WLzI: { downloadId: undefined, key: <Buffer a4 61 07 15 67 1d 02 1c cd c1 b3 74 37 8a 29 94 11 79 7b 74 9d c7 9b c3 58 ad 76 63 eb 55 4c ce>, api: { keepalive: false, counterId: 1908482752, sid: '5r4fUf4IxvRsBJl6TBdHjEJJWUgtX1RQNExZEYBFy1BFBsWIP5V3Jbapig', _events: [Object] }, nodeId: 'UV12WLzI', timestamp: 1390922020, type: 0, directory: false, size: 585, attributes: { n: 'delete.js', c: '6LNpaEWClytCkGdExssTWgRt6eZS' }, name: 'delete.js', parent: { downloadId: undefined, key: undefined, api: [Object], nodeId: 'Ud1Q0bCL', timestamp: 1361048675, type: 2, directory: true, name: 'Cloud Drive', children: [Object] } } }

tonistiigi commented 10 years ago

Sorry.

var ids = Object.keys(storage.files).filter(function(f) { return storage.files[f].name === 'filename.txt'})
manvir-singh commented 10 years ago

I will try that when I get home leave open for now thanks

manvir-singh commented 10 years ago

thanks it works now