我从npm安装了rets-client
包。
我跑了其他query
并得到meta
工作正常,但当我试图做photo streaming example
我一直在收到错误
Error: RetsReplyError: RETS Server reply while attempting getObject - ReplyCode 20403 (NO_OBJECT_FOUND); ReplyText: No Object Found [260978536:1].
我按照示例中的代码进行操作 https://github.com/sbruno81/rets-client#photo-streaming-example
try {
rets.getAutoLogoutClient(clientSettings, async (client) => {
const photoIds = {
'260978536': '*', // get all photos for listingId 260978536
};
const photoStream = await client.objects.stream.getObjects('Property', 'Photo', photoIds, {
alwaysGroupObjects: true,
ObjectData: '*'
});
console.log("========================================");
console.log("======== Photo Stream Results ========");
console.log("========================================");
return new Promise(function (resolve, reject) {
let i = 0;
photoStream.objectStream.on('data', function (event) {
try {
if (event.type === 'headerInfo') {
console.log(' ~~~~~~~~~ Header Info ~~~~~~~~~');
outputFields(event.headerInfo);
return
}
console.log(" -------- Photo " + (i + 1) + " --------");
if (event.type === 'error') {
console.log(" Error: " + event.error);
} else if (event.type === 'dataStream') {
outputFields(event.headerInfo);
fileStream = fs.createWriteStream(
"/tmp/photo_" + event.headerInfo.contentId + "_" + event.headerInfo.objectId + "." + event.headerInfo.contentType.match(/\w+\/(\w+)/i)[1]);
event.dataStream.pipe(fileStream);
}
i++;
} catch (err) {
reject(err);
}
});
photoStream.objectStream.on('error', function (errorInfo) {
reject(errorInfo);
});
photoStream.objectStream.on('end', function () {
resolve();
});
})
})
} catch (errorInfo) {
const error = errorInfo.error || errorInfo;
console.log(" ERROR: issue encountered:");
outputFields(error);
console.log(' ' + (error.stack || error).replace(/\n/g, '\n '));
}
我使用那张照片的原因是因为当我查询时我可以看到这个列表id有PictureCount
的20
,但不知怎的,它给了我没有找到的对象。
样本列表查询返回相同的id
{ L_Area: 'Islands-Van. & Gulf',
L_ListingID: '260978536',
L_Status: 'Expired',
L_PictureCount: '20',
L_Last_Photo_updt: '2015-07-15T04:27:00',
L_DisplayId: 'V1064230' }
有人可以帮我看看我在这里做错了吗?提前感谢您的任何帮助和建议。
附:我也尝试使用一个L_ListingID
与L_Status
作为Active
而不是Expired
,但结果是相同的
您要连接的RETS服务器不允许图像下载,因为它是一个临时服务器,他们希望保持较低的带宽。您必须针对其生产服务器测试代码,或要求MLS允许从其临时环境下载。
从RETS服务器下载图像时需要注意的事项: