|
@@ -422,13 +422,9 @@ public interface RemoteFile {
|
|
* 上传后不会发送文件消息, 即官方客户端只能在 "群文件" 中查看文件.
|
|
* 上传后不会发送文件消息, 即官方客户端只能在 "群文件" 中查看文件.
|
|
* 可通过 [toMessage] 获取到文件消息并通过 [Group.sendMessage] 发送, 或使用 [uploadAndSend].
|
|
* 可通过 [toMessage] 获取到文件消息并通过 [Group.sendMessage] 发送, 或使用 [uploadAndSend].
|
|
*
|
|
*
|
|
- * ## 已弃用
|
|
|
|
- *
|
|
|
|
- * 使用 [sendFile] 代替. 本函数会上传文件但不会发送文件消息.
|
|
|
|
- * 不发送文件消息就导致其他操作都几乎不能完成, 而且经反馈, 用户通常会忘记后续的 [RemoteFile.toMessage] 操作.
|
|
|
|
- * 本函数造成了很大的不必要的迷惑, 故以既上传又发送消息的, 与官方客户端行为相同的 [sendFile] 代替.
|
|
|
|
- *
|
|
|
|
- * 相关问题: [#1250: 群文件在上传后 toRemoteFile 返回 null](https://github.com/mamoe/mirai/issues/1250)
|
|
|
|
|
|
+ * 若 [RemoteFile.id] 存在且旧文件存在, 将会覆盖旧文件.
|
|
|
|
+ * 即使用 [resolve] 或 [resolveSibling] 获取到的 [RemoteFile] 的 [upload] 总是上传一个新文件,
|
|
|
|
+ * 而使用 [resolveById] 或 [listFiles] 获取到的总是覆盖旧文件, 当旧文件已在远程删除时上传一个新文件.
|
|
*
|
|
*
|
|
*
|
|
*
|
|
* **注意**: [resource] 仅表示资源数据, 而不带有文件名属性.
|
|
* **注意**: [resource] 仅表示资源数据, 而不带有文件名属性.
|
|
@@ -446,9 +442,6 @@ public interface RemoteFile {
|
|
* @param callback 进度回调
|
|
* @param callback 进度回调
|
|
* @throws IllegalStateException 该文件上传失败或权限不足时抛出
|
|
* @throws IllegalStateException 该文件上传失败或权限不足时抛出
|
|
*/
|
|
*/
|
|
- @Deprecated(
|
|
|
|
- "Use uploadAndSend instead.", ReplaceWith("this.uploadAndSend(resource, callback)"), DeprecationLevel.WARNING
|
|
|
|
- ) // deprecated since 2.7-M1
|
|
|
|
public suspend fun upload(
|
|
public suspend fun upload(
|
|
resource: ExternalResource,
|
|
resource: ExternalResource,
|
|
callback: ProgressionCallback? = null,
|
|
callback: ProgressionCallback? = null,
|
|
@@ -456,26 +449,14 @@ public interface RemoteFile {
|
|
|
|
|
|
/**
|
|
/**
|
|
* 上传文件到 [RemoteFile.path] 表示的路径.
|
|
* 上传文件到 [RemoteFile.path] 表示的路径.
|
|
- * ## 已弃用
|
|
|
|
- * 阅读 [upload] 获取更多信息
|
|
|
|
* @see upload
|
|
* @see upload
|
|
*/
|
|
*/
|
|
- @Suppress("DEPRECATION")
|
|
|
|
- @Deprecated(
|
|
|
|
- "Use uploadAndSend instead.", ReplaceWith("this.uploadAndSend(resource)"), DeprecationLevel.WARNING
|
|
|
|
- ) // deprecated since 2.7-M1
|
|
|
|
public suspend fun upload(resource: ExternalResource): FileMessage = upload(resource, null)
|
|
public suspend fun upload(resource: ExternalResource): FileMessage = upload(resource, null)
|
|
|
|
|
|
/**
|
|
/**
|
|
* 上传文件.
|
|
* 上传文件.
|
|
- * ## 已弃用
|
|
|
|
- * 阅读 [upload] 获取更多信息
|
|
|
|
* @see upload
|
|
* @see upload
|
|
*/
|
|
*/
|
|
- @Suppress("DEPRECATION")
|
|
|
|
- @Deprecated(
|
|
|
|
- "Use uploadAndSend instead.", ReplaceWith("this.uploadAndSend(file, callback)"), DeprecationLevel.WARNING
|
|
|
|
- ) // deprecated since 2.7-M1
|
|
|
|
public suspend fun upload(
|
|
public suspend fun upload(
|
|
file: File,
|
|
file: File,
|
|
callback: ProgressionCallback? = null,
|
|
callback: ProgressionCallback? = null,
|
|
@@ -483,23 +464,12 @@ public interface RemoteFile {
|
|
|
|
|
|
/**
|
|
/**
|
|
* 上传文件.
|
|
* 上传文件.
|
|
- * ## 已弃用
|
|
|
|
- * 阅读 [upload] 获取更多信息
|
|
|
|
* @see upload
|
|
* @see upload
|
|
*/
|
|
*/
|
|
- @Suppress("DEPRECATION")
|
|
|
|
- @Deprecated(
|
|
|
|
- "Use sendFile instead.", ReplaceWith("this.uploadAndSend(file)"), DeprecationLevel.WARNING
|
|
|
|
- ) // deprecated since 2.7-M1
|
|
|
|
public suspend fun upload(file: File): FileMessage = file.toExternalResource().use { upload(it) }
|
|
public suspend fun upload(file: File): FileMessage = file.toExternalResource().use { upload(it) }
|
|
|
|
|
|
/**
|
|
/**
|
|
* 上传文件并发送文件消息.
|
|
* 上传文件并发送文件消息.
|
|
- *
|
|
|
|
- * 若 [RemoteFile.id] 存在且旧文件存在, 将会覆盖旧文件.
|
|
|
|
- * 即使用 [resolve] 或 [resolveSibling] 获取到的 [RemoteFile] 的 [upload] 总是上传一个新文件,
|
|
|
|
- * 而使用 [resolveById] 或 [listFiles] 获取到的总是覆盖旧文件, 当旧文件已在远程删除时上传一个新文件.
|
|
|
|
- *
|
|
|
|
* @param resource 需要上传的文件资源. 无论上传是否成功, 本函数都不会关闭 [resource].
|
|
* @param resource 需要上传的文件资源. 无论上传是否成功, 本函数都不会关闭 [resource].
|
|
* @see upload
|
|
* @see upload
|
|
*/
|
|
*/
|
|
@@ -555,24 +525,12 @@ public interface RemoteFile {
|
|
|
|
|
|
/**
|
|
/**
|
|
* 上传文件并获取文件消息, 但不发送.
|
|
* 上传文件并获取文件消息, 但不发送.
|
|
- *
|
|
|
|
- * ## 已弃用
|
|
|
|
- * 在 [upload] 获取更多信息
|
|
|
|
- *
|
|
|
|
* @param path 远程路径. 起始字符为 '/'. 如 '/foo/bar.txt'
|
|
* @param path 远程路径. 起始字符为 '/'. 如 '/foo/bar.txt'
|
|
* @param resource 需要上传的文件资源. 无论上传是否成功, 本函数都不会关闭 [resource].
|
|
* @param resource 需要上传的文件资源. 无论上传是否成功, 本函数都不会关闭 [resource].
|
|
* @see RemoteFile.upload
|
|
* @see RemoteFile.upload
|
|
*/
|
|
*/
|
|
@JvmStatic
|
|
@JvmStatic
|
|
@JvmOverloads
|
|
@JvmOverloads
|
|
- @Deprecated(
|
|
|
|
- "Use sendFile instead.",
|
|
|
|
- ReplaceWith(
|
|
|
|
- "this.sendFile(path, resource, callback)",
|
|
|
|
- "net.mamoe.mirai.utils.RemoteFile.Companion.sendFile"
|
|
|
|
- ),
|
|
|
|
- level = DeprecationLevel.WARNING
|
|
|
|
- ) // deprecated since 2.7-M1
|
|
|
|
public suspend fun FileSupported.uploadFile(
|
|
public suspend fun FileSupported.uploadFile(
|
|
path: String,
|
|
path: String,
|
|
resource: ExternalResource,
|
|
resource: ExternalResource,
|
|
@@ -581,22 +539,11 @@ public interface RemoteFile {
|
|
|
|
|
|
/**
|
|
/**
|
|
* 上传文件并获取文件消息, 但不发送.
|
|
* 上传文件并获取文件消息, 但不发送.
|
|
- * ## 已弃用
|
|
|
|
- * 阅读 [uploadFile] 获取更多信息.
|
|
|
|
- *
|
|
|
|
* @param path 远程路径. 起始字符为 '/'. 如 '/foo/bar.txt'
|
|
* @param path 远程路径. 起始字符为 '/'. 如 '/foo/bar.txt'
|
|
* @see RemoteFile.upload
|
|
* @see RemoteFile.upload
|
|
*/
|
|
*/
|
|
@JvmStatic
|
|
@JvmStatic
|
|
@JvmOverloads
|
|
@JvmOverloads
|
|
- @Deprecated(
|
|
|
|
- "Use sendFile instead.",
|
|
|
|
- ReplaceWith(
|
|
|
|
- "this.sendFile(path, file, callback)",
|
|
|
|
- "net.mamoe.mirai.utils.RemoteFile.Companion.sendFile"
|
|
|
|
- ),
|
|
|
|
- level = DeprecationLevel.WARNING
|
|
|
|
- ) // deprecated since 2.7-M1
|
|
|
|
public suspend fun FileSupported.uploadFile(
|
|
public suspend fun FileSupported.uploadFile(
|
|
path: String,
|
|
path: String,
|
|
file: File,
|
|
file: File,
|
|
@@ -606,7 +553,7 @@ public interface RemoteFile {
|
|
/**
|
|
/**
|
|
* 上传文件并发送文件消息到相关 [FileSupported].
|
|
* 上传文件并发送文件消息到相关 [FileSupported].
|
|
* @param resource 需要上传的文件资源. 无论上传是否成功, 本函数都不会关闭 [resource].
|
|
* @param resource 需要上传的文件资源. 无论上传是否成功, 本函数都不会关闭 [resource].
|
|
- * @see RemoteFile.uploadAndSend
|
|
|
|
|
|
+ * @see RemoteFile.upload
|
|
*/
|
|
*/
|
|
@JvmStatic
|
|
@JvmStatic
|
|
@JvmOverloads
|
|
@JvmOverloads
|
|
@@ -620,7 +567,7 @@ public interface RemoteFile {
|
|
|
|
|
|
/**
|
|
/**
|
|
* 上传文件并发送文件消息到相关 [FileSupported].
|
|
* 上传文件并发送文件消息到相关 [FileSupported].
|
|
- * @see RemoteFile.uploadAndSend
|
|
|
|
|
|
+ * @see RemoteFile.upload
|
|
*/
|
|
*/
|
|
@JvmStatic
|
|
@JvmStatic
|
|
@JvmOverloads
|
|
@JvmOverloads
|