As of April 12th, you must go to Progress SupportLink to create new support cases or to access existing cases. Please, bookmark the SupportLink URL and use the new portal to contact the support team.
You can save a reference (similar to how you save relations with kinveyRef) to a file in a collection column. It will automatically resolve when fetching against the collection, and using the returned object you can grab and use the _downloadURL.
d
dualpandas
said
over 9 years ago
cool, last question hopefully but how can i set $kinvey.File.stream('image1'); to a variable instead of image1? everytime I try to use a variable I get a 404.
d
dualpandas
said
over 9 years ago
So here is where my code is currently, I am trying to get the file._download url to save to the collection under an existing place._id in the column img_url but it keeps creating a new row and saving it in the img_url column there instead.
$scope.streamFile = function(){
$scope.place._id;
$scope.url={};
var promise = $kinvey.File.stream($scope.place._id); // if i make this a simple name of id it
//streams but if i try this $scope it doesnt work.
promise.then(function(file) {
$scope.url = file._downloadURL;
$scope.place.img_url = $scope.url;
var iurl= {
img_url: {
_type : 'KinveyFile',
_id : $scope.place._id
}
};
var promise = $kinvey.DataStore.save('Collection', iurl);
});
}
M
Mark
said
over 9 years ago
To update, you’d have to set the `iurl._id`. Looking at your code, it seems like you want to add the url to the `$scope.place`? If so, something like the code below will do:
```
// Retrieve the file._downloadURL etc.
$scope.place.img_url = {
_type: 'KinveyFile',
_id: $scope.place._id
};
var promise = $kinvey.DataStore.save('Collection', $scope.place);
```
d
dualpandas
said
over 9 years ago
so I tried what you suggested:
$scope.streamFile = function(){
$scope.place._id;
var promise = $kinvey.File.stream($scope.place._id);
promise.then(function(file) {
$scope.murl= file._downloadURL;
$scope.place.img_url= $scope.url;
$scope.truck.img_url = {
_type : 'KinveyFile',
_id : $scope.place._id
};
var promise = $kinvey.DataStore.save('Collection', $scope.place._id);
});
}
however it doesn't work :( I get a 404 error.
M
Mark
said
over 9 years ago
The 404 indicates the `$kinvey.File.stream` fails. Have you actually uploaded the file with id `$scope.place._id`?
d
dualpandas
said
over 9 years ago
So after taking some time away from this, I am attempting to try again.
my issue is still that when I try and save, it creates an entirely new row in the collection. I found Update datastore in the kinvey references but cannot get it to work. http://devcenter.kinvey.com/angular/reference/api/Kinvey.DataStore.html
I now get ReferenceError: _id is not defined errors
var promise = $kinvey.File.upload(theFile, {
_filename : theFile.name,
public : true,
size : theFile.size,
mimeType : theFile.type
}).then(function(_fileData) { debugger;
// now it should save the file parent, and create the relationship
// using the file _id
//currently only creates a new row not appended to existing data
dualpandas
when I use the following to access an image I can see in the Kinvey console, I get a 404 error.
scope.streamFile = function(){
var promise = $kinvey.File.stream('image1');
promise.then(function(file) {
var url = file._downloadURL;
});
}