-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avfile missing data #35
Conversation
merge form leancloud
return new JSONObject(toHashMap()); | ||
} | ||
|
||
public Map<String, Object> toHashMap() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
函数名建议改成 toMap()
case StorageTypeS3: | ||
file.setName((String) map.get(AVObject.OBJECT_ID)); | ||
break; | ||
default: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
健壮性: 这里 switch 需要列举出所有 StorageType,然后 default
块抛出不支持此类型的异常,
即使是不需要的处理也要直接break
,
目的是防止日后新增类型之后没有因没有改动此处逻辑导致一些无法捕捉的事后 bug
// we store the objectId in file.name | ||
result.put("id", getName()); | ||
break; | ||
default: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同下,default
抛异常
* "51a306fce4b06e53feb1d95f", "updatedAt": "2013-05-27T07:10:52.000Z", "url": | ||
* "https://s3-ap-northeast-1.amazonaws.com/avos-cloud/b60b1e29-5314-4538-9759-2cb6d6c74185" } | ||
*/ | ||
public static Map<String, Object> mapFromFile(AVFile file) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
建议保留方法,并标注@Deprecated
,实现可以直接换成 file.toMap()
return result; | ||
} | ||
|
||
public static AVFile fileFromMap(Map<String, Object> map) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同上
主要修复的问题:AVFile 与 HashMap 转换时部分字段丢失。
另外,AVFile 与 HashMap 转换的代码从 AVUtils 迁移到了 AVFile。