question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Hi, I was looking for some component to quickly navigate a file system, and yours is really fast!!! But I can’t upload a file 😦 I’m using angular 4 and formData, somethink like this:

formData.append(files, file.fileEntry.resultFile, file.relativePath);

but it seem not work. Can you help? thanks.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
jacobbuttoncommented, Jan 19, 2018

You should be handling the files in the dropped event. You also need to wait for file.fileEntry.file(info => {}) to finish before pushing your formData to the server. Try this.

@Component({
	selector: 'app-upload',
	templateUrl: './upload.html',
	styleUrls: ['./upload.css']
})
export class UploadComponent {

	constructor(private http: HttpClient) {}

	public dropped(event) {
		let formData = new FormData();
		for (let i = 0; i < event.files.length; i++) {
			event.files[i].fileEntry.file(file => {
				formData.append("files", file, event.files[i].relativePath);
				if (i === event.files.length - 1) {
					this.http.post('http://localhost:8080/rest/upload/files', formData)
						.subscribe(() => console.log("request done with success"));
				}
			});
		}
	}

	public fileOver(event) {
		console.log(event);
	}

	public fileLeave(event) {
		console.log(event);
	}
}
0reactions
rcristaldicommented, Jan 20, 2018

Great! It’s work. Thanks very much.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Easyupload.io - Upload files for free and transfer big files easily.
Easyupload.io offers free file upload, file sharing and file transfer service without any need for registration. Upload your files and share them with...
Read more >
Upload Files Of Any Size – Free Up To 5 GB - Filemail
Upload files free and share anonymously using a direct download link. No download limits. No Ads. No need to register. Share more with...
Read more >
file.io - Super simple file sharing
Sharing files with file.io is convenient, anonymous and secure. Just upload files and share the links via email, SMS, Slack, Discord, etc.
Read more >
Dropbox.com
Canvas. Upload course files or assignments straight from Dropbox to Canvas.
Read more >
WeTransfer - Send Large Files & Share Photos Online - Up to ...
WeTransfer is the simplest way to send your files around the world. Share large files and photos. Transfer up to 2GB free. File...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found