nextcloud 1.0.16

  • Readme
  • Changelog
  • Example
  • Installing
  • 77

nextcloud #

A Nextcloud client for dart

Features #

  • Creating directories, removing directories and files
  • Uploading and downloading files
  • Directory listing
  • Get a user's full name and the groups the user belongs to
  • Move and copy files and folders
  • Create shares, update them and delete them. All share types supported (except federate cloud sharing)
  • Search for users to share a file or folder with (sharees)

Usage/Example #

https://github.com/Viktoriaschule/dart-nextcloud/blob/master/example/example.dart

v1.0.16 #

  • Add zip directory downloading

v1.0.15 #

  • Add download streaming

v1.0.14 #

  • Update example URLs
  • Fix pub scoring

v1.0.13 #

  • Update homepage URL

v1.0.12 #

  • Fix binary data upload and download

v1.0.11 #

  • Fix dependency constraints

v1.0.10 #

  • Fix dependency conflict with flutter

v1.0.9 #

  • Fix performance issues

v1.0.8 #

  • Add share type to sharees and webdav
  • Fix share permissions

v1.0.7 #

  • Add sharees search feature

v1.0.6 #

  • Add shares feature

v1.0.5 #

  • Fix web headers

v1.0.4 #

  • Fix upload body

v1.0.3 #

  • Add move and copy operations

v1.0.2 #

  • Change structure
  • Fix everything for web

v1.0.1 #

  • Fix download
  • Add content type

v1.0.0 #

  • Initial commit

example/example.dart

import 'dart:convert';
import 'dart:io';

import 'package:nextcloud/nextcloud.dart';
import 'package:nextcloud/src/shares/share.dart';

Future main() async {
  try {
    final client = NextCloudClient('cloud.example.com', 'myuser', 'mypassword');
    await client.webDav
        .upload(File('example/test.png').readAsBytesSync(), '/test.png');
    File('example/bla.png')
        .writeAsBytesSync(await client.webDav.download('/test.png'));
    await client.webDav.upload(utf8.encode('Test file'), '/test.txt');
    await listFiles(client);
    await client.webDav.move('/test.txt', '/abc.txt');
    await listFiles(client);
    await client.webDav.copy('/abc.txt', '/test.txt');
    await listFiles(client);

    final userData = await client.metaData.getMetaData();
    print(userData.fullName);
    print(userData.groups);

    // Sharing example
    print('Share file:');
    final share = await client.shares.shareWithUser('/test.txt', 'USER',
        permissions: Permissions([Permission.read, Permission.update]));
    print(share);
    print('List shared files');
    print((await client.shares.getShares(path: '/test.txt', reshares: false))
        .join('\n'));
    await client.shares.updateShareNote(share.id, 'Test notice');
    print('New note:');
    print(await client.shares.getShare(share.id));
    print('Delete share');
    await client.shares.deleteShare(share.id);
    print(
        'List shared files: ${(await client.shares.getShares(path: '/test.txt', reshares: false)).length}');

    print('Download /test.txt ...');
    final downloadedData = await client.webDav.downloadStream('/test.txt');

    final file = File('example/test.txt');
    if (file.existsSync()) {
      file.deleteSync();
    }
    final inputStream = file.openWrite();
    await inputStream.addStream(downloadedData);
    await inputStream.close();

    print('... done!');

    await client.webDav.delete('/test.txt');
    await client.webDav.delete('/abc.txt');

    print('List all sharees:');
    print(await client.sharees.getSharees('', 1000, 'file'));
  } on RequestException catch (e, stacktrace) {
    print(e.cause);
    print(e.toString());
    print(stacktrace);
  }
}

Future listFiles(NextCloudClient client) async {
  final files = await client.webDav.ls('/');
  for (final file in files) {
    print(file.path);
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  nextcloud: ^1.0.16

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:nextcloud/nextcloud.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
58
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
77
Learn more about scoring.

We analyzed this package on Apr 3, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6

Maintenance issues and suggestions

Support latest dependencies. (-10 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency (xml).

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.3.0 <3.0.0
http >=0.12.0 <0.13.0 0.12.0+4
intl >=0.16.0 <0.17.0 0.16.1
xml >=3.0.0 <4.0.0 3.7.0 4.1.0
Transitive dependencies
async 2.4.1
charcode 1.1.3
collection 1.14.12
convert 2.1.1
http_parser 3.1.4
meta 1.1.8
path 1.6.4
pedantic 1.9.0
petitparser 3.0.2
source_span 1.7.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6