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.
In the Console, you should see a new entry created in that collection (with image column storing the _KinveyRef and the newly uploaded file should appear under “Console->Data->Files (Select Files instead of a collection)”).
In the Console, you should see a new entry created in that collection (with image column storing the _KinveyRef and the newly uploaded file should appear under “Console->Data->Files (Select Files instead of a collection)”).
Could you check it on your side , maybe its a defect?
PS: Thank you I will also try to use KCSFileStore
K
Kinvey Support
said
over 7 years ago
Wood,
Are you using KCSPersistable protocol which is required while mapping classes to Kinvey backend?
Also, you can use KCSFileStore to store and retrieve files using id. Files can be of any format. For more information, please check http://devcenter.kinvey.com/ios/guides/files#Downloading.
Wood Wayfarer
I have property UIImage
h. file
@property (nonatomic, copy) UIImage *exampleImage;
m.file
- (NSDictionary *)hostToKinveyPropertyMapping{
return @{
@"exampletId" : KCSEntityKeyId,
@"exampleImage" : @"image"
};
}
+(NSDictionary *) kinveyPropertyToCollectionMapping
{
return @{@"coverage":KCSFileStoreCollectionName};
}
Can I fetch from backend UIImage instead of NSDictionary for property exampleImage?
Wood,
Just trying to summarize the steps for uploading images:
Step 1: Define the class :
class Image : NSObject { //all NSObjects in Kinvey implicitly implement KCSPersistable
var entityId: String! //Kinvey entity _id
var image: UIImage!
}
Step 2: Override the hostToKinveyPropertyMapping & kinveyPropertyToCollectionMapping method:
override func hostToKinveyPropertyMapping() -> [NSObject : AnyObject]! {
return [
"entityId" : KCSEntityKeyId, //the required _id field
"image" : "image"
]
}
override class func kinveyPropertyToCollectionMapping() -> [NSObject : AnyObject]! {
return [
"image" : KCSFileStoreCollectionName
]
}
Step 3: Initialize store object with KCSLinkedAppDataStore object.
var collection = KCSCollection(fromString: "Images", ofClass:Image.self)
var imageToSend = KCSLinkedAppdataStore.storeWithOptions([
KCSStoreKeyResource : collection,
KCSStoreKeyCachePolicy : KCSCachePolicy.Both.rawValue,
KCSStoreKeyOfflineUpdateEnabled : true
])
Step 4: Upload the Object as follows:
let imageSendingData = Image()
imageSendingData.image = UIImage(data: UIImageJPEGRepresentation(image, 0.5)!)
imageToSend.saveObject(imageSendingData, withCompletionBlock: { (objectsOrNil, errorOrNil) -> Void in
if errorOrNil != nil {
print("Error saving image: \(errorOrNil)")
} else {
print("Save image successful")
}
}, withProgressBlock: nil)
In the Console, you should see a new entry created in that collection (with image column storing the _KinveyRef and the newly uploaded file should appear under “Console->Data->Files (Select Files instead of a collection)”).
Thanks,
Pranav
Kinvey Support
- Oldest First
- Popular
- Newest First
Sorted by Newest FirstPranav J
Wood,
Just trying to summarize the steps for uploading images:
Step 1: Define the class :
class Image : NSObject { //all NSObjects in Kinvey implicitly implement KCSPersistable
var entityId: String! //Kinvey entity _id
var image: UIImage!
}
Step 2: Override the hostToKinveyPropertyMapping & kinveyPropertyToCollectionMapping method:
override func hostToKinveyPropertyMapping() -> [NSObject : AnyObject]! {
return [
"entityId" : KCSEntityKeyId, //the required _id field
"image" : "image"
]
}
override class func kinveyPropertyToCollectionMapping() -> [NSObject : AnyObject]! {
return [
"image" : KCSFileStoreCollectionName
]
}
Step 3: Initialize store object with KCSLinkedAppDataStore object.
var collection = KCSCollection(fromString: "Images", ofClass:Image.self)
var imageToSend = KCSLinkedAppdataStore.storeWithOptions([
KCSStoreKeyResource : collection,
KCSStoreKeyCachePolicy : KCSCachePolicy.Both.rawValue,
KCSStoreKeyOfflineUpdateEnabled : true
])
Step 4: Upload the Object as follows:
let imageSendingData = Image()
imageSendingData.image = UIImage(data: UIImageJPEGRepresentation(image, 0.5)!)
imageToSend.saveObject(imageSendingData, withCompletionBlock: { (objectsOrNil, errorOrNil) -> Void in
if errorOrNil != nil {
print("Error saving image: \(errorOrNil)")
} else {
print("Save image successful")
}
}, withProgressBlock: nil)
In the Console, you should see a new entry created in that collection (with image column storing the _KinveyRef and the newly uploaded file should appear under “Console->Data->Files (Select Files instead of a collection)”).
Thanks,
Pranav
Kinvey Support
Wood Wayfarer
Yes I am using KCSPersistable
@interface Examples : NSObject <KCSPersistable>
@property (nonatomic, copy, readonly) NSString *exampleObjectId;
@property (nonatomic, copy) UIImage *exampleImage;
Could you check it on your side , maybe its a defect?
PS: Thank you I will also try to use KCSFileStore
Kinvey Support
Wood,
Are you using KCSPersistable protocol which is required while mapping classes to Kinvey backend?
Also, you can use KCSFileStore to store and retrieve files using id. Files can be of any format. For more information, please check http://devcenter.kinvey.com/ios/guides/files#Downloading.
Thanks,
Pranav
-
Why do I get "Undefined symbols" errors when building with KinveyKit?
-
How do I register push tokens?
-
When using social login, to perform a log-out, do I need to log out of the social network, Kinvey, o
-
How can I assign additional properties to users?
-
Does KinveyKit support 64-bit ARM devices, such as iPhone 5s?
-
Authorization Token Invalid or Expired
-
BOOL and how it is stored in the database.
-
Offline saving throwing errors
-
Custom endpoint not able to form request object
-
Security through business logic
See all 437 topics