Giter Site home page Giter Site logo

Comments (10)

mdxiaohu avatar mdxiaohu commented on May 23, 2024

I have reviewed some questions and responses regarding this method.

Will the onBeforeRequest method necessarily be triggered when onSuccess is triggered?
Can I determine the type of method in onBeforeRequest to determine if the upload was successful.

For example, when the type is PATCH, it can be confirmed that the current file has been successfully uploaded.

I don't know if my understanding is correct.

from tus-js-client.

mdxiaohu avatar mdxiaohu commented on May 23, 2024

hello

from tus-js-client.

Acconut avatar Acconut commented on May 23, 2024

Have a look at the upload.url property (https://github.com/tus/tus-js-client/blob/main/docs/api.md#tusuploadurl). This might be what you are looking for.

from tus-js-client.

mdxiaohu avatar mdxiaohu commented on May 23, 2024

Perhaps language translation may lead to misunderstandings.
To be precise, what I want to ask is the return parameter of onSuccess.

for example: #304

from tus-js-client.

mdxiaohu avatar mdxiaohu commented on May 23, 2024

I may not have explained it clearly, but I think I should describe my problem again.

After uploading the file, the onSuccess method will be triggered.
But the onSuccess method does not have any return value.

I use the uppy open-source library in combination to upload multiple files.
In the absence of a return value for onSuccess, I don't know which file has already been uploaded.

The current plan is to have two solutions.

The first option:

Currently, it has been observed that onSuccess triggers onBeforeRequest before each trigger.

onBeforeRequest(req, file) {
    console.log(req, file, 'req, file')
    if (req._method == 'PATCH' && file.source) {
	    this.saveObj = {
		    fileId: file.source,
		    fileUrl: req._url
	    }
    }
},

Determine the corresponding parameters and save the information of the file that is about to be uploaded.

The second option:

I don't know if onSuccess can return parameters like onBeforeRequest.
Just like below.

onSuccess(req, file) {
    console.log(req, file, 'req, file')
}

I am not sure if the first method is feasible, and for the second method, it is necessary to extend the open source library, which I am not sure if it is feasible.

from tus-js-client.

Acconut avatar Acconut commented on May 23, 2024

I am still confused about what you are actually trying to achieve here. What do you mean by "file address"? Are you trying to retrieve some data returned from the server? Or do you just want to identify which files are uploaded when Uppy emits an event?

from tus-js-client.

mdxiaohu avatar mdxiaohu commented on May 23, 2024

Thank you for your reply.
b
When the file is successfully uploaded, a URL will be returned, which is the address of the file on the server.
This is the onBeforeRequest method, which callback parameters when triggered.
You can access files through this address, just like accessing image resources on a server.
https://github.com/logo.png

from tus-js-client.

Acconut avatar Acconut commented on May 23, 2024

tus-js-client exposes this URL through its Upload#url property, as explained above. I am not sure how you can access this URL through Uppy. That question is best asked to the Uppy engineers directly.

However, it seems like Uppy emit a special event that includes the URL once the upload is finished: https://github.com/transloadit/uppy/blob/df11d2bc83eea2894e294f69947ba779e6b60711/packages/%40uppy/tus/src/index.js#L270-L277

from tus-js-client.

mdxiaohu avatar mdxiaohu commented on May 23, 2024

You are really amazing, thank you very much.
I once thought that "upload-success" would only take effect when using "@upload/xhr-upload".

from tus-js-client.

Acconut avatar Acconut commented on May 23, 2024

Glad I could help!

I once thought that "upload-success" would only take effect when using "@upload/xhr-upload".

Maybe that's something that can be improved in the documentation, @arturi @Murderlon @aduh95?

from tus-js-client.

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.