小编Raf*_*lli的帖子

通过 POST 将文件传递给 NodeJS,然后传递给另一个 API 而不保存在磁盘上

我需要在 React UI(使用 axios)中接收来自用户的文件,使用 Express 通过 POST 将该文件发送到 NodeJS 方法,然后,我需要通过 POST 将这个相同的文件直接发送到另一个 API(.NET WebAPI)无需保存在磁盘上。我试图直接传递数据文件 (req.files.file.data),但 .NET API 无法识别请求中的文件。

是否有可能在“var”中创建一个临时文件并像从磁盘读取文件时那样发送它?

此示例适用于本地文件:

var formData = {
  form: "{ abn: '666666666' }",
  files: JSON.stringify([
    { 
      name: "file1", 
      type: "1", 
      number: "6666" 
    },
    { 
      name: "file2",
      type: "3", 
      number: "3333" 
    },
  ]),
  // Pass multiple values /w an Array
  attachments: [
    fs.createReadStream(__dirname + '/../file1.txt'),
    fs.createReadStream(__dirname + '/../file2.txt')
   ],
};
var reqs = request.post({url:'https://tms-dev-api.micway.com.au/api/company/file', formData: formData, json: true}, function optionalCallback(err, response, body) {
  if (err) …
Run Code Online (Sandbox Code Playgroud)

javascript node.js express asp.net-web-api axios

7
推荐指数
1
解决办法
938
查看次数

Azure 注销重定向 (post_logout_redirect_uri) 不起作用

完成注销后,Azure 注销页面不会重定向用户。它只返回这条消息:

您已退出帐户。关闭所有浏览器窗口是个好主意。

我尝试了不同的注销 URL:

但它们根本不起作用。

唯一奇怪的是,如果我检查 DevTools 上的“网络”选项卡,页面似乎正在加载重定向的网站内容,但没有在浏览器上显示它。

redirect azure azure-active-directory

6
推荐指数
1
解决办法
9503
查看次数

使用 Azure AD、ReactJS 和 NodeJS 对用户进行身份验证并使用图形 API

我有一个使用 NodeJS + ReactJS 创建的项目应用程序,我想要的只是使用 Azure AD 来验证用户身份并使用 Azure 的 Graph API 获取他的数据,如姓名、组、图片、职业等。

我已经在 Azure 门户上正确配置了 Azure AD 和应用程序。包括权限委派和所有这些员工。

我试图了解如何做到这一点但没有成功。我一直试图在 google、StackOverflow、Microsoft 文档,甚至项目示例上找到。

一些示例已经工作,但没有一个我可以理解并放入我的项目中作为生产应用程序工作。

我已将其用于对用户进行身份验证,但返回的 AccessToken 对调用 Graph API 无效:

passport.use(new OIDCStrategy({
    redirectUrl: config.creds.returnURL,
    realm: config.creds.realm,
    clientID: config.creds.clientID,
    clientSecret: config.creds.clientSecret,
    oidcIssuer: config.creds.issuer,
    identityMetadata: config.creds.identityMetadata,
    skipUserProfile: config.creds.skipUserProfile,
    responseType: config.creds.responseType,
    responseMode: config.creds.responseMode,
    allowHttpForRedirectUrl: config.creds.allowHttpForRedirectUrl
  },
  function(iss, sub, profile, accessToken, refreshToken, done) {
    console.log(accessToken);
    profile = profile._json;
    if (!profile.email) {
      return done(new Error("No email found"), null);
    }
    // asynchronous verification, for effect...
    process.nextTick(function () …
Run Code Online (Sandbox Code Playgroud)

azure node.js reactjs passport.js azure-ad-graph-api

5
推荐指数
1
解决办法
3341
查看次数

Jest无法正常运行Create-React-App“无法从componentY找到模块nodeModuleX”

我正在尝试开始测试使用Jest通过Create React App创建的项目中的组件。我为一个组件创建了一个简单的测试文件,并且从与我要测试的组件甚至不相关的组件中获取“错误”。我正在使用Create React App,因此无法更改Jest的配置。

那是测试文件

/** Home.test.js */

import React from 'react';
import ReactDOM from 'react-dom';
import Home from '../../components/Home';

test('renders without crashing', () => {
    const div = document.createElement('div');
    ReactDOM.render(<Home />, div);
 });
Run Code Online (Sandbox Code Playgroud)

那是错误

FAIL  src\__tests__\components\Home.test.js
  ? Test suite failed to run

    Cannot find module 'signature_pad' from 'Signature.jsx'

      at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:179:17)
      at Object.<anonymous> (src/components/common/inputs/Signature.jsx:3:22)

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        1.031s
Ran all test suites related to changed files.
Run Code Online (Sandbox Code Playgroud)

如果在组件Signature.jsx上注释代码的导入行,则会从另一个组件收到另一个错误:

src\__tests__\components\Home.test.js …
Run Code Online (Sandbox Code Playgroud)

reactjs jestjs enzyme

5
推荐指数
0
解决办法
365
查看次数

Azure 地图 - 我可以获得道路的速度限制吗?

我正在尝试使用 API 获取地图上特定点(纬度、经度)的速度限制,但在 Azure Maps 文档中找不到它。我在 Bing 地图上找到了它,但如果可能的话,我想使用 Azure 地图,因为它们每月为您提供 25 万个地图免费请求。

谢谢!

azure bing-maps azure-maps

1
推荐指数
1
解决办法
913
查看次数