Coder Social home page Coder Social logo

Comments (3)

mymikemiller avatar mymikemiller commented on June 15, 2024

Note that when I modify your code to set the "authorization" header to the format given here, which skips signing and instead embeds the access/secret key directly, the upload succeeds.

from aws_s3_client.

inshyma avatar inshyma commented on June 15, 2024

+1 @mymikemiller did u solve it?

from aws_s3_client.

mymikemiller avatar mymikemiller commented on June 15, 2024

Nope. I switched to using Internet Archive's ia command line tool (docs here). My Dart code below uses Process.run to launch it. For authorization, credentialsFilePath references the file generated with the following command:

./ia --config-file '.ia-{SCREEN_NAME}' configure

SCREEN_NAME can be found and set at https://archive.org/account/index.php?settings=1 when logged in, but should be lowercased and have spaces replaced with underscores to match what is seen after the '@' in the url for the user's library page at https://archive.org/details/@my_screen_name.

final args = [
  '--config-file',
  '$credentialsFilePath',
  'upload',
  '$identifier',
  '${file.path}',
  '--remote-name=$identifier.mp4',
  '--size-hint=${file.lengthSync()}',
  '--no-derive',
  '--metadata=mediatype:movies',
  '--metadata=collection:opensource_movies',
];
await Process.run('./ia', args);

I actually use Process.start to get upload progress by regex matching on stderr as it uploads. Here's that code in case it's useful to someone:

await Process.start('./ia', args)
    .then((p) async {
  p.stderr.transform(Utf8Decoder()).listen((String data) {
    if (data.contains('This item has been taken offline')) {
      // Probably shouldn't throw here, but for now it's ok as this only
      // happens when the user deletes a video off ia, then tries to
      // reupload with the same name. TODO: add retry logic that
      // automatically changes the name
      throw ('Upload failed. A video with the same name was probably previously deleted from this internet archive account. Consider changing the name and retrying.');
    }

    final progressRegex = RegExp(r'(\d+)%');
    final progressMatch = progressRegex.firstMatch(data);
    if (progressMatch != null) {
      final progress = double.parse(progressMatch.group(1));
      callback?.call(progress);
    }
  });

  final exitCode = await p.exitCode;
  if (exitCode != 0) {
    throw 'upload error (exit code $exitCode)';
  }
});

If anyone out there has comments on how I can improve my code, I'd love feedback. I'm still new to Dart.

from aws_s3_client.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.