来自IOHandler.ReadStream的Memo1.Lines.LoadFromStream(Memo1.Lines.LoadFromStream from IOHandler.ReadStream)
我试图将发送的文本文件显示到memo.lines而不将其保存到磁盘
从服务器
try Ms := TMemoryStream.Create; Ms.LoadFromFile('update.txt'); Ms.Position := 0; AContext.Connection.IOHandler.LargeStream := True; AContext.Connection.IOHandler.Write(Ms, 0, True); finally Ms.Free; end;
对客户...我不知道如何在客户端做到这一点
try Ms := TMemoryStream.Create; Ms.Position := 0; IdTCPClient1.IOHandler.LargeStream := True; IdTCPClient1.Connection.IOHandler.ReadStream(Ms, -1,false); finally Memo1.Lines.LoadFromStream(Ms); Ms.Free; end;
任何人都可以帮助我如何使这项工作成为可能吗?
I was trying to display the sent textfile to memo.lines with out saving it to a disk
from server
try Ms := TMemoryStream.Create; Ms.LoadFromFile('update.txt'); Ms.Position := 0; AContext.Connection.IOHandler.LargeStream := True; AContext.Connection.IOHandler.Write(Ms, 0, True); finally Ms.Free; end;
to client...im not sure how to do this in client
try Ms := TMemoryStream.Create; Ms.Position := 0; IdTCPClient1.IOHandler.LargeStream := True; IdTCPClient1.Connection.IOHandler.ReadStream(Ms, -1,false); finally Memo1.Lines.LoadFromStream(Ms); Ms.Free; end;
can anyone help me on how to make this work if its possible ?
原文:https://stackoverflow.com/questions/18059136
最满意答案
您正在使用
onCreate()
,这就是为什么在数据库中更改条件值时不会执行该函数的原因。现在,如果您在位置
condition
添加新数据,则onCreate()将被触发。
onUpdate()
,在实时数据库中更新数据时触发。
onWrite()
,在实时数据库中创建,更新或删除数据时触发。
onDelete()
,在从实时数据库中删除数据时触发。如果要在数据更改时触发,请尝试使用
onWrite()
或onUpdate()
。有关详情,请访问: https : //firebase.google.com/docs/functions/database-events
You are using
onCreate()
that is why the function does not get executed if you change condition value in the database.Now if you add new data at location
condition
, then onCreate() will get triggered.
onUpdate()
, which triggers when data is updated in the Realtime Database.
onWrite()
, which triggers when data is created, updated, or deleted in the Realtime Database.
onDelete()
, which triggers when data is deleted from the Realtime Database.Try and use
onWrite()
oronUpdate()
if you want it to trigger when data is changed.more info here: https://firebase.google.com/docs/functions/database-events
相关问答
更多-
childByAutoId()适用于iOS SDK。 对于admin.Database() ,请使用push() 。 var reference = admin.database().ref(path).push(); childByAutoId() is for the iOS SDK. For admin.Database(), use push(). var reference = admin.database().ref(path).push();
-
在Firebase云端函数数据库触发器中发出PUT请求(Make a PUT request in Firebase Cloud Function database trigger)[2024-03-08]
如果您希望使用其他任何可以解决/拒绝的承诺,应始终从函数返回承诺。 如果你没有回复别人使用的承诺,为什么你使用承诺? 假设你有一个解决承诺的功能: function somePromise(){ Promise.resolve('yay') } 如果你没有兑现承诺,那么这将失败。 somePromise().then(yay => console.log(yay) 这将试图在undefined上运行.then函数(这是undefined函数的返回值)。 所以你必须返回附带.then函数的承诺。 f ... -
如果您只想在添加付款明细时更新余额 ,则可以直接在付款明细上使用onCreate触发器。 尝试类似的东西(你必须更新你的案例的代码): exports.calculateBalance = functions.database.ref('payments/{pushId}/paymentDetails/{detailId}').onCreate(event => { var paymentRef = event.data.adminRef.parent.parent; var payment ...
-
如何通过Firebase中的HTTP触发器功能更新数据库?(How to update database via HTTP trigger function in firebase?)[2022-07-03]
正如道格在评论中提到的那样,这是无效的。 如果您想从HTTP触发功能访问数据库,则需要使用Server Admin SDK 。 你的代码如下所示: const functions = require('firebase-functions'); const admin = require('firebase-admin'); admin.initializeApp(functions.config().firebase); exports.email = functions.https.onRequest ... -
您不能在与您的函数不在同一个项目中的数据库上放置触发器。 instance()仅适用于同一项目中的数据库分片。 You can't put a trigger on a database that's not in the same project as your functions. instance() only works with database shards in the same project.
-
那么你一定一直在看错误的样本和文档。 关于创建第一个函数的文档中的这个例子有一个例子: const admin = require('firebase-admin'); // Take the text parameter passed to this HTTP endpoint and insert it into the // Realtime Database under the path /messages/:pushId/original exports.addMessage = functio ...
-
您将需要使用firebase-admin const functions = require('firebase-functions'); const admin = require('firebase-admin'); admin.initializeApp(functions.config().firebase); return admin.database().ref('...').push( {foo: 'someValue'} ); You will need to use fire ...
-
触发数据库功能时,云功能会从触发向下的点传入数据。 要从数据库中的其他位置获取任何数据,您需要在代码中读取该数据。 通过从event.data.ref导航来访问附近的数据 所以,如果你有一个兄弟admin : const functions = require('firebase-functions'); const admin = require('firebase-admin'); admin.initializeApp(functions.config().firebase); exports.o ...
-
您正在使用onCreate() ,这就是为什么在数据库中更改条件值时不会执行该函数的原因。 现在,如果您在位置condition添加新数据,则onCreate()将被触发。 onUpdate() ,在实时数据库中更新数据时触发。 onWrite() ,在实时数据库中创建,更新或删除数据时触发。 onDelete() ,在从实时数据库中删除数据时触发。 如果要在数据更改时触发,请尝试使用onWrite()或onUpdate() 。 有关详情,请访问: https : //firebase.google.com ...
-
这将有助于您: https : //firebase.google.com/docs/reference/js/firebase.database.OnDisconnect 创建一个onWrite事件,让我们说/ disconnected / {user} 假设您使用Swift进行编码,可以使用以下代码: dataRef.child("disconnected").onDisconnectUpdateChildValues(["uid" : user.uid]) //ofcourse change data ...