Upload file to CouchDB
See original GitHub issueI’m trying to upload an image with the following code:
$scope.onFileSelect = function(ins, files) {
_.each(files, function(file) {
var fileReader = new FileReader();
fileReader.onload = function(e) {
$timeout(function() {
file.previewUrl = e.target.result;
});
};
fileReader.readAsDataURL(file);
$upload.upload({
url: projectRepository.attachmentUrl(ins, file.name),
method: "PUT",
file: file,
}).progress(function (evt) {
console.log(evt);
}).success(function(data) {
// ...
}).error(function(data) {
console.log(data);
});
});
};
I’m uploading the file to CouchDB (which I don’t think matters since CouchDB doesn’t do any processing on the file) and the uploaded file end up with the content type “application/json”. I fixed that by setting the headers manually with
headers: { "Content-Type": file.type },
And outcommenting the line in the angular-file-upload source that sets the content type to undefined. This fixes the content type, and sets it correctly according to the filetype but the uploaded file still ends up on the server in some corrupted form that won’t show correctly in the browser.
Issue Analytics
- State:
- Created 10 years ago
- Comments:15 (6 by maintainers)
Top Results From Across the Web
CouchDB Attaching Files - Tutorialspoint
To do so, click on the Upload Attachment button. A dialog box will appear where you can choose the file to be uploaded....
Read more >1.4.2. /db/doc/attachment — Apache CouchDB® 3.2 ...
Returns the file attachment associated with the document. ... Uploads the supplied content as an attachment to the specified document.
Read more >CouchDB Attach Files to Document - YouTube
Learn how to attach files in the document using CouchDB.
Read more >Uploading file to PouchDB/CouchDB - Stack Overflow
Now, i've got to the point where I need to add a function to upload (multiple) files to a document. (files like ....
Read more >Learn CouchDB Attach Files in CouchDB Tutorial (19255)
With this option, you can upload a new attachment like file, image, or document, to the database. In order to do this, click...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hello how i change to Multiple File Input Fields in One Form
version 1.2.0 now supports this: