Coder Social home page Coder Social logo

ratakondalaarun / shelf_virtual_directory Goto Github PK

View Code? Open in Web Editor NEW
4.0 1.0 3.0 4.68 MB

A dart package provides a virtual directory to serve static files from a directory.

Home Page: https://pub.dev/packages/shelf_virtual_directory

License: MIT License

Dart 92.46% HTML 4.58% JavaScript 1.55% CSS 1.40%
shelf dart-library dart dart-shelf shelf-static static-file-handler

shelf_virtual_directory's Introduction

Hi! I'm Ratakondala Arun

Github Github twitter

Hi, I'm Ratakondala Arun, a passionate self-taught flutter developer from India. I spend most of my time building ๐Ÿ”ง awesome things.

  • ๐Ÿ”ญI'm currently working on flutter
  • ๐ŸŒฑI'm currently learning flutter
  • ๐Ÿ‘ฏโ€โ™€๏ธI'm looking to collaborate on tmdb_api
  • โ”Ask me about anything here

Languages and tools

Flutter Dart Git nodejs javascript

dart | javascript | flutter | nodejs | express | Git | Github | Google cloud

Ratakondala Arun

Top Langs

shelf_virtual_directory's People

Contributors

ratakondalaarun avatar yeungkc avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

shelf_virtual_directory's Issues

ERR_EMPTY_RESPONSE : I got error while trying to serve android internal storage downlod folder

I got an error while trying to serve files over the http server from android download folder.

I dont know why it works fine on android emulator but not works the same appication in real android device : realme 6 runnig android 10

File storage Permissions granted :

  1. Emulator pixel 6 pro API 30 : Allow acces to media only
  2. Realme 6 android 10: Allow

Code i tried :

`Future localShelf() async {
// serving directory
const folderToServe = 'storage/emulated/0/Download/';
final address = InternetAddress.loopbackIPv4;
const port = 8989;

// creates a [ShelfVirtualDirectory] instance and provides a [Router] instance.
final folderPath = p.join(
Directory.current.path,
folderToServe,
);
final virDir = ShelfVirtualDirectory(folderPath);

final apiRouter = Router()
..mount('/routerstatic/', virDir.router)
..mount('/mountstatic/', virDir.handler)
..mount('/nodirlisting/',
ShelfVirtualDirectory(folderPath, listDirectory: true).handler)
// ..mount('/fsrootstatic/', ShelfVirtualDirectory('/').handler)
..get('/getstatic/', virDir.handler)
..get('/api/user', () => Response.ok('/api/user'))
..get('/api', (
) => Response.ok('/api'))
..mount('/', virDir.handler);

// using [Pipeline] from shelf we can add a logging middleware.
// we can use handler provided by [Router] instance.
final pipline =
const Pipeline().addMiddleware(logRequests()).addHandler(apiRouter);

// add the handler to [Cascade]
final server = await io.serve(
pipline,
address,
port,
);

print('Server is running at http://${server.address.host}:${server.port}');
}`

rootFolderName get faild

when i use this code to get handler.

final virDirHandler = ShelfVirtualDirectory('/').handler;

and exec shelf io.server(virDirHandler,xxx,xxx);
it will crash in virtual_directory.dart line 99

    final rootFolderName = ([..._rootDir.uri.pathSegments]..removeLast()).last;

because _rootDir.uri.pathSegments is empty list.

New files does not get served untill application restart

I noticed that static files (for example images) added to the virtual directory while the application is already running does not get served until you restart the application again. I am using shelf_virtual_directory version 2.0.0 on Windows 10. My application was compiled to a console exe and running as a windows service.

Cheers

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.