thomasooo / spring-boot-tus Goto Github PK
View Code? Open in Web Editor NEWJava spring boot implementation of TUS (resumable file uploads) protocol
License: MIT License
Java spring boot implementation of TUS (resumable file uploads) protocol
License: MIT License
if u use Content-Length header some client will return a error
Hi,
I am sending one file from browser and uploading to server, it is chunking and uploading to the server.
But while uploading it is giving exception
you can get the github link for the implementation:
) https://github.com/tus/tus-js-client
Spring server implementation
2) https://github.com/thomasooo/spring-boot-tus
java.nio.file.FileSystemException: storage\5b87e2a903751c247c164465: The process cannot access the file because it is being used by another process.
at sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:86) ~[?:1.8.0_144]
at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:97) ~[?:1.8.0_144]
at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:102) ~[?:1.8.0_144]
at sun.nio.fs.WindowsFileSystemProvider.implDelete(WindowsFileSystemProvider.java:269) ~[?:1.8.0_144]
at sun.nio.fs.AbstractFileSystemProvider.deleteIfExists(AbstractFileSystemProvider.java:108) ~[?:1.8.0_144]
at java.nio.file.Files.deleteIfExists(Files.java:1165) ~[?:1.8.0_144]
at java.nio.file.Files.copy(Files.java:3004) ~[?:1.8.0_144]
at tusserver.storage.services.StorageServiceImpl.processStream(StorageServiceImpl.java:84) ~[classes/:?]
at tusserver.StorageController.processPatch(StorageController.java:186) ~[classes/:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_144]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_144]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_144]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_144]
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205) ~[spring-web-4.3.11.RELEASE.jar:4.3.11.RELEASE
Code :
public int processStream(String uuid, InputStream inputStream) throws Exception {
String filename = StringUtils.cleanPath(uuid);
File file = new File(storageDir.resolve(filename).toString());
if (!file.isFile()){
new FileOutputStream(file).close();
if(!file.isFile()){
log.error("Cannot create new file");
throw new TusPermissionDeniedException("Cannot create new file");
}
}
InputStream storageFile;
try{
storageFile = new FileInputStream(file);
}catch(IOException e){
log.error("Cannot read old file");
throw new TusPermissionDeniedException("Cannot read old file");
}
// File fileToBeInstalled = new File(StorageServiceImpl.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath());
// Files.copy(fileToBeInstalled.toPath(), storageDir.resolve(filename), StandardCopyOption.REPLACE_EXISTING);
// fileToBeInstalled.delete();
storageFile = new SequenceInputStream(storageFile, inputStream);
// at this position giving exception
Files.copy(storageFile, storageDir.resolve(filename), StandardCopyOption.REPLACE_EXISTING);
file = new File(storageDir.resolve(filename).toString());
return (int) file.length();
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.