Comments (4)
Hello,
Please send me your code.
Most likely you've been using it in a functional component.
from react-native-chunk-upload.
class App extends Component {
constructor() {
super();
this.state = {
videoFile: {},
};
}
sendVideo = () => {
const chunk = new ChunkUpload({
path: this.state.videoFile.path, // Path to the file
size: 10024, // Chunk size (must be multiples of 3)
fileName: this.state.videoFile.fileName, // Original file name
fileSize: this.state.videoFile.size, // Original file size
// Errors
onFetchBlobError: (e) => console.log(e),
onWriteFileError: (e) => console.log(e),
});
chunk.digIn(this.upload.bind(this));
upload(file, next, retry, unlink) {
const body = new FormData();
body.append('video', file.blob); // param name
Axios.post('vod/submitStep1', body, {
headers: {
'Content-Type': 'multipart/form-data',
Accept: 'application/json',
'x-chunk-number': file.headers['x-chunk-number'],
'x-chunk-total-number': file.headers['x-chunk-total-number'],
'x-chunk-size': file.headers['x-chunk-size'],
'x-file-name': file.headers['x-file-name'],
'x-file-size': file.headers['x-file-size'],
'x-file-identity': file.headers['x-file-identity'],
},
})
.then((response) => {
switch (response.status) {
case 200:
console.log(response.data);
break;
case 201:
console.log(`${response.data.progress}% uploaded...`);
next();
break;
}
})
.catch((error) => {
if (error.response) {
if ([400, 404, 415, 500, 501].includes(error.response.status)) {
console.log(error.response.status, 'Failed to upload the chunk.');
unlink(file.path);
} else if (error.response.status === 422) {
console.log('Validation Error', error.response.data);
unlink(file.path);
} else {
console.log('Re-uploading the chunk...');
retry();
}
} else {
console.log('Re-uploading the chunk...');
retry();
}
});
}
}
Hello,
Please send me your code.
Most likely you've been using it in a functional component.
here you are
from react-native-chunk-upload.
Add a }
before the upload
function.
sendVideo = () => {
const chunk = new ChunkUpload({
path: this.state.videoFile.path, // Path to the file
size: 10024, // Chunk size (must be multiples of 3)
fileName: this.state.videoFile.fileName, // Original file name
fileSize: this.state.videoFile.size, // Original file size
// Errors
onFetchBlobError: (e) => console.log(e),
onWriteFileError: (e) => console.log(e),
});
chunk.digIn(this.upload.bind(this));
} // You've forgotten a closing curly brace
from react-native-chunk-upload.
thanks i got it
from react-native-chunk-upload.
Related Issues (11)
- Error after running `npm run web` HOT 1
- video from gallery not working
- I think should have custom field in Header in namespace ChunkUpload
- how to get total chunks count
- No such file HOT 1
- Blob error = Error: File does not exist at path in iOS HOT 1
- File does not exist at path : onFetchBlobError HOT 3
- Using with MUX HOT 9
- Any example about uploading the file to express server?
- Memory error when uploading larger videos HOT 7
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 react-native-chunk-upload.