Giter VIP home page Giter VIP logo

Comments (13)

ankitpokhrel avatar ankitpokhrel commented on May 25, 2024

@s1rc I added a rough doc for Laravel integration: https://github.com/ankitpokhrel/tus-php/wiki/Laravel-&-Lumen-Integration

from tus-php.

s1rc avatar s1rc commented on May 25, 2024

Thank you, I will give this a try!

from tus-php.

s1rc avatar s1rc commented on May 25, 2024

So far so good!

One quick change to your Wiki article. In the route definition, the parameter needs to be optional.

Route::any('/tus/{any?}', function () {
    $response = app('tus-server')->serve();

    return $response->send();
})->where('any', '.*');

from tus-php.

ankitpokhrel avatar ankitpokhrel commented on May 25, 2024

Yes true, thanks :)

from tus-php.

s1rc avatar s1rc commented on May 25, 2024

Not sure if I should open a new issue, but do have some follow up questions.

  1. Where are the files stored during upload? In the redis cache?
  2. If using redis cache I cannot resume, if using file cache upload finishes 100% immediately. (both using Uppy)
  3. Is there a completion handler for the server? I want to perform some post upload actions (i.e. add to a media library and remove from the tus upload directory)

from tus-php.

ankitpokhrel avatar ankitpokhrel commented on May 25, 2024
  1. Files are stored in the location you specify while setting up the server. By default, it uses uploads folder in the installation directory.

    ->setUploadDir(storage_path('app/public/uploads')); // upload dir
    
  2. Make sure that tus-server can connect the redis server. You can use REDIS_HOST and REDIS_PORT env to pass redis host and port. You can also directly create and pass redis object.

    // TusServiceProvider.php
    
    $redis = new TusPhp\Cache\RedisStore([
        'host' => '127.0.0.1',
        'port' => '6379',
    ]);
    
    $server = new Server($redis);
    

    if using file cache upload finishes 100% immediately

    I guess you are testing in your local setup. This is related to uppy and the reason is that the progress bar is updated as soon as the first byte is sent to the server. This process is too fast in local and it reaches 100% immediately. If you use actual server this won't happen.

  3. No there isn't but if you are using uppy you can use upload-success event for post upload operations.

from tus-php.

s1rc avatar s1rc commented on May 25, 2024
  1. I have it set to the following, and that's where the files end up after completion. I can see when at 100% the files are being copied into that directory, however I can't find the partially uploaded files.
$server
     ->setApiPath('/tus')
     ->setUploadDir(storage_path('tus'));
  1. I can see that redis is working locally, since I am connected to it in a viewer and the records are visible. When I run run with the default files cache the upload is instantly 100% but nothing ends up in the upload dir.

  2. Ok I understand, so I'd have to have Uppy perform another API call and then send the delete event to the Tus server.

from tus-php.

ankitpokhrel avatar ankitpokhrel commented on May 25, 2024

Hi @s1rc,

I just tried in one of my Laravel's installation and it seems to be working fine. I hope you properly setup your tus endpoint for uppy.

const uppy = Uppy.Core({debug: true, autoProceed: false})
    .use(Uppy.Dashboard, {target: '#uppyUploader', inline: true})
    .use(Uppy.Tus, {endpoint: 'http://your.app/tus'}) // tus endpoint
    .run()

Note that if you upload same file again while was successfully uploaded previously it won't get uploaded unless you clear your redis or file cache. File cache is saved in .cache/tus_php.cache.

Flush your cache first and then try uploading some large files and pause it after a while even if uppy shows 100%. You should see partially uploaded file in your uploads dir. Resume it again and when the upload completes, you should be able to see the complete file.

from tus-php.

s1rc avatar s1rc commented on May 25, 2024

I set it up exactly as you wrote the Wiki.

I've tried file cache and deleting vendor/ankitpokhrel/tus-php/.cache/tus_php.cache, as well as deleting all records from redis when using redis config.

During upload there are no partially uploaded files in the folder defined at setUploadDir(storage_path('tus'))

I've tried setting the Laravel environment cache to file and redis, no change.

You can see here that pausing and resuming the file just starts over
https://ufile.io/dv2ao

And when a file is at 100% there is a long pause while the file is copied into the folder defined at ``setUploadDir(storage_path('tus'))`
https://ufile.io/ilv9p

from tus-php.

ankitpokhrel avatar ankitpokhrel commented on May 25, 2024

Hi @s1rc,

The progress bar is updated by uppy as soon as the first byte is sent to the server and don't wait for the actual byte to be updated. This process is very quick in local so the progress bar reaches 100% immediately. This won't happen in actual server as there will be lag when sending first byte to the server.

You can see here that pausing and resuming the file just starts over

I see that the file is 2.5gb which will take some time to upload (even partially). Try by uploading small file lets say 50 mb. When the progress bar reaches 100%, wait for 2-3 seconds and pause it, there should be partially uploaded file in your uploads dir.

And when a file is at 100% there is a long pause while the file is copied into the folder

There is long pause because file is now actually being uploaded to the server. Again, this happens only in local because of the way uppy progress bar works.

If you have a test server, I recommend you to check on that and things will be clear for you.

I know this is confusing but it happens only in local and I haven't found a way to fixed that yet. If you can figure out how to fix it that would be a great help. I will try to check with uppy team later.

from tus-php.

s1rc avatar s1rc commented on May 25, 2024

@ankitpokhrel thanks for the feedback.

I tested it on a development server on AWS and it does seem to be working better.

from tus-php.

ankitpokhrel avatar ankitpokhrel commented on May 25, 2024

I will try to replicate the issue as soon as I get some time and will get back to you

from tus-php.

ankitpokhrel avatar ankitpokhrel commented on May 25, 2024

Closed in favor of #44

from tus-php.

Related Issues (20)

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.