Comments (10)
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.
from tus-js-client.
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.
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.
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.
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.
Thank you for your reply.
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.
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.
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.
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)
- MIT License HOT 2
- tus-upload large file not working in Ubuntu nginx server HOT 3
- Switch from HTTPS to HTTP Causes Mixed Content Errors HOT 1
- It's not possible to declare onShouldRetry and fallback to the default behaviour HOT 1
- Failed because: Error: tus: unexpected response while uploading chunk, [...] HOT 12
- define a global maximum concurrent request limit HOT 3
- > net::ERR_UPLOAD_FILE_CHANGED
- TypeError: Cannot read properties of undefined (reading 'Upload') HOT 4
- Base64 Encoding of Metadata Assumes Metadata Value is a UTF8 String (Should It?) HOT 6
- RetryDelays: "Type 'null' is not assignable to type 'number[] | undefined'". But null is acceptable. HOT 2
- Replace Karma test runner
- window is undefined when trying to run in worker file on browser HOT 8
- Duplicate calls to `start` cause duplicate uploads
- Provide fallback storage when using tus in Web Workers HOT 3
- Either a Bug or i'm doing something wrong HOT 3
- removeFingerprintOnSuccess not working on multiple files HOT 4
- Decrease browser bundle size HOT 1
- Change request method to PATCH HOT 3
- How to set creator, Signed URL and Allowed Origins on Cloudflare TUS Upload HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tus-js-client.