-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Description
I'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.
Metadata
Metadata
Assignees
Labels
No labels