@@ -134,16 +134,7 @@ - (instancetype)initWithData:(NSData *)data
134134 mimeType ?: @" application/octet-stream" ;
135135 });
136136
137- _rawJSONData[kLCFile_metaData ] = ({
138-
139- NSMutableDictionary *metaData = [NSMutableDictionary dictionary ];
140- metaData[kLCFile_size ] = @(data.length );
141- NSString *objectId = LCPaasClient.sharedInstance .currentUser .objectId ;
142- if (objectId && objectId.length > 0 ) {
143- metaData[kLCFile_owner ] = objectId;
144- }
145- metaData.copy ;
146- });
137+ _rawJSONData[kLCFile_metaData ] = @{ kLCFile_size : @(data.length ) };
147138
148139 _ACL = ({
149140
@@ -196,16 +187,8 @@ - (instancetype)initWithLocalPath:(NSString *)localPath
196187 mimeType ?: @" application/octet-stream" ;
197188 });
198189
199- _rawJSONData[kLCFile_metaData ] = ({
200-
201- NSMutableDictionary *metaData = [NSMutableDictionary dictionary ];
202- metaData[kLCFile_size ] = fileAttributes[NSFileSize ];
203- NSString *objectId = [LCPaasClient sharedInstance ].currentUser .objectId ;
204- if (objectId && objectId.length > 0 ) {
205- metaData[kLCFile_owner ] = objectId;
206- }
207- metaData.copy ;
208- });
190+ NSNumber *fileSize = fileAttributes[NSFileSize ];
191+ _rawJSONData[kLCFile_metaData ] = fileSize ? @{ kLCFile_size : fileSize } : @{};
209192
210193 _ACL = ({
211194
@@ -247,7 +230,7 @@ - (instancetype)initWithRemoteURL:(NSURL *)remoteURL
247230 mimeType ?: @" application/octet-stream" ;
248231 });
249232
250- _rawJSONData[kLCFile_metaData ] = @{ kLCFile___source : @" external" };
233+ _rawJSONData[kLCFile_metaData ] = @{ @" __source " : @" external" };
251234
252235 _ACL = ({
253236
@@ -425,7 +408,7 @@ - (NSString *)url {
425408- (NSDictionary *)metaData {
426409 __block NSDictionary *metaData;
427410 [self internalSyncLock: ^{
428- metaData = [LCFile decodingMetaDataFromDic :self ->_rawJSONData];
411+ metaData = [NSDictionary _lc_decoding :self ->_rawJSONData key: kLCFile_metaData ];
429412 }];
430413 return metaData;
431414}
@@ -667,6 +650,7 @@ - (void)uploadLocalDataWithData:(NSData *)data
667650 completionHandler : (void (^)(BOOL succeeded, NSError *error))completionHandler
668651{
669652 NSMutableDictionary *parameters = [self rawJSONDataMutableCopy ];
653+ [parameters removeObjectsForKeys: @[@" __type" , @" className" ]];
670654 [self getFileTokensWithParameters: parameters callback: ^(LCFileTokens *fileTokens, NSError *error) {
671655
672656 if (error) {
@@ -1285,19 +1269,6 @@ + (NSString *)decodingObjectIdFromDic:(NSDictionary *)dic
12851269 return value;
12861270}
12871271
1288- + (NSDictionary *)decodingMetaDataFromDic : (NSDictionary *)dic
1289- {
1290- /* @note For compatibility, should decoding multiple keys ... ... */
1291-
1292- NSDictionary *value = [NSDictionary _lc_decoding: dic key: kLCFile_metaData ];
1293-
1294- if (value) { return value; }
1295-
1296- value = [NSDictionary _lc_decoding: dic key: kLCFile_metadata ];
1297-
1298- return value;
1299- }
1300-
13011272// MARK: Compatibility
13021273
13031274- (void )saveInBackgroundWithBlock : (void (^)(BOOL , NSError * _Nullable))block
0 commit comments