使用SwaggerHub和OpenAPI 2规格,这就是我将此文件上传工作的方式。让我知道您是否有任何疑问。这是用YAML而不是JSON规格编写的。它花了一些阅读和一些实验,但这是GCLOUD文档: htttps:htttps:// cloud。 google.com/storage/docs/uploading-objects
以及SwaggerHub信息:
/upload/storage/v1/b/{bucket}/o?uploadType=media&name={objectName}:
post:
summary: Upload an object directly to a bucket
description: Upload an object directly to a bucket
consumes:
- multipart/form-data
produces:
- application/json
parameters:
- in: header
name: Authorization
type: string
required: true
- in: path
name: bucket
required: true
type: string
description: The name of the bucket to upload to.
- in: path
name: objectName
required: true
type: string
description: The name the object will receive in the bucket.
- in: header
name: Content-Type
type: string
required: true
description: The content type of the upload. Ex. text/plain
- in: formData
name: fileToUpload
type: file
description: The file to upload.
responses:
200:
description: OK
204:
description: Success - No Content
400:
description: Bad Request
401:
description: Insufficient Privileges
404:
description: Not Found
它确实接受类型:formdata请求中的文件。
,它使用配置(例如)将typecript转换为javaScript,捆绑sass,少文件,捆绑svg文件等
首先, webpack是一种构建工具 是一种反应样板,在引擎盖下使用 babel和webpack,已经为最常见的方案提供了配置,因此您不必担心 它。
从您的问题中不清楚,初始化的意思是什么。我只能假设您的意思是用中等简单的学习曲线引导应用程序。如果是这种情况,CRA是必经之路。
在您的代码中, total_encontrado
是 2
,它大于或等于 1
。结果,您给出 #select
的条件始终是正确的,因此它选择了每个字符的索引。然后,您将其映射到索引。
相反,您可能只想选择匹配 letra_procurada
的字母。
palavra_secreta = "programador"
letra_procurada = "a"
total_encontrado = palavra_secreta.count letra_procurada
palavra_secreta_array = palavra_secreta.split("")
puts palavra_secreta_array
.each_with_index
.select { |letra, index| letra_procurada == letra }
.map { |pair| pair[1] }
您也可以使用 #FILTER_MAP
(Ruby 2.7及以后)来简化这一点。
palavra_secreta = "programador"
letra_procurada = "a"
total_encontrado = palavra_secreta.count letra_procurada
palavra_secreta_array = palavra_secreta.split("")
puts palavra_secreta_array
.each_with_index
.filter_map { |letra, index| index if letra_procurada == letra }
同样重要的是要记住,听众必须收听所有主节点的通知。
请参阅: https://github.com/spring-projects/springs/springs/springs/spring -DATA-REDIS/eskity/1782
添加生菜属性以与群集解决问题联系。我的配置:
data:
redis:
password: your-password
ssl:
enabled: true
cluster:
nodes: node-address
lettuce:
cluster:
refresh:
dynamic-refresh-sources: false
period: PT1S
pool:
max-active: 15
max-wait: -1
max-idle: -1
min-idle: 5
我不确定您在这里问什么...为什么代码不起作用?
说明:
首先,我很确定至少 的一部分是 time
和 timer()
的输出 strings 您都将其连接在一起,然后试图以数字为单位。
当您进行时间 + Time()
时,它与“ 12:48:39” + Timer()
相同,例如,如果计时器的输出为0:01 :12(秒= 72),那与做:
"12:48:39" + "0:01:12"
它只会输出“ 12:48:390:01:12”
,因为它将加成两个字符串。
当您将其传递到 parseint()
中时,您本质上是在做:
parseInt("12:48:390:01:12")
parseint()
不知道该怎么办,因为它不是简单的数字,所以它只会解析起点并扔掉其余的;它将返回 12
,第一个数字。
解决方案:
因此...如果您的目标是添加两次,我建议使用 date
,它允许您正确存储日期和时间。请参阅:在javascript中添加两个日期
希望这会有所帮助
我最近一直在处理很多序列化,并在处理值类型的无数据数据时发现了以下文章和帖子。
如何使c#中的xmlSerializer在c# - serialization 中详细介绍XMLSerialializer的漂亮技巧。具体而言,XMLSerialier寻找XXXSPEFIFIED BOOLEAN属性以确定是否应包括在内,这使您可以忽略nulls。
亚历克斯·斯科德利(Alex Scordellis)问了一个stackoverflow问题,该问题收到一个很好的答案。亚历克斯还在他的博客上做了很好的文章,他试图解决 使用XmlSerializer将其验证为无效的< int> 。
问题在于
Jasmine仅导出 Jasmine.js
file,
"exports": "./lib/jasmine.js"
但在中Jasmine-ts 代码需要命令文件(围绕第164行),
const Command = require("jasmine/lib/command");
现在此文件不是导出的一部分,因此它会引发错误:
错误:软件包subpath'./lib/command'未通过“ exports”定义
来修复此茉莉花需要导出 jasmine-ts
使用的命令文件。
我在茉莉 package.json
中测试了以下更改,并解决了问题:
"exports": {
".": "./lib/jasmine.js",
"./lib/command": "./lib/command.js"
}
更改Jasmine package.json
不是一个很好的解决方案,但目前这是唯一的解决方案我的头顶。
我将尝试向茉莉花GitHub存储库打开问题。
尝试以下代码:
import smtplib
from email.utils import formataddr
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
msg = MIMEMultipart()
body_part = MIMEText('Write you text here.')
user = '[email protected]'
password = 'xxxx'
msg['Subject'] = 'You subject'
msg['From'] = formataddr(('yyyyy', '[email protected]'))
msg['To'] = '[email protected]'
msg.attach(body_part)
smtp_obj = smtplib.SMTP_SSL("smtp.gmail.com", 465)
smtp_obj.login(user, password)
smtp_obj.sendmail(msg['From'], msg['To'], msg.as_string())
smtp_obj.quit()
更新:如何将文件附加到电子邮件:
只需将以下行添加到上面的脚本中即可。
from email.mime.application import MIMEApplication
path = './../' #The path of your file.
with open(path + filename,'rb') as file:
msg.attach(MIMEApplication(file.read(), Name='filename'))
您的USERCONTROL没有BO类实例。您只需在SerialPortinItControl中定义BO类,因此,当您创建它的Instanse时,它将是这样的:
var instBO = new SerialPortInitControl.BO.BO_GetValues()
因此,您创建了BO类的对象,但是当您将其存储在UserConrol中时?
public partial class SerialPortInitControl : UserControl
{
public class BO
{
public class BO_GetValues
{
public string name;
public string baudRate;
public string paritie;
public string dataBits;
public string stopBits;
}
}
//instance of BO class
public BO BO_Instanse {get;}
//instance of BO.Get_Values class
public BO.BO_GetValues BO_GetValues_Instanse {get;}
public SerialPortInitControl()
{
InitializeComponent();
BO_Instanse = new BO();
BO_GetValues_Instanse = new BO.BO_GetValues();
}
public bool GetValues(out BO.BO_GetValues values, ref string errorMessage)
{
if(BO_Instanse == null)//need real code here
{
values = new BO.BO_GetValues()
{
name = CBX_Name.Text,
baudRate = CBX_BaudRate.Text,
paritie = CBX_Parity.Text,
dataBits = CBX_DataBits.Text,
stopBits = CBX_StopBits.Text,
};
return true;
}
else
{
values = null;
errorMessage = "Checking failed! " + errorMessage;
return false;
}
}
}
因此,这将有效:
var control = new SerialPortInitControl();
var bo = control.BO_Instanse;
var bo_values = control.BO_GetValues_Instanse;
您也可以在没有USERCORTROL类的情况下创建类的实例:
var boInstanse = new SerialPortInitControl.BO();
var boGetValues_Instanse = new SerialPortInitControl.BO.BO_GetValues();
模拟 auth0.useauth0
要访问模块的模块,以通配符导入导入整个模块,并避免命名导入。另外, vi.mocked()
支持。它没有模拟任何东西。
而不是这样
import { useAuth0 } from '@auth0/auth0-vue' ❌
vi.mock('@auth0/auth0-vue')
const mockedUseAuth0 = vi.mocked(useAuth0, true) ❌
:
import * as auth0 from '@auth0/auth0-vue' ✅
vi.mock('@auth0/auth0-vue')
,
describe('NavBar.vue', () => {
it('does something', async () => {
我做到了:
- 我创建了2位作家,并与CompositeItemWriter联系在一起,
- 我通过DTO传递了DTO,参考失败或/和成功处理的参考数据的错误。
- DTO仅用于通过处理器向作家。
- 每个作者都检查DTO是否具有您各自的数据。如果有成功数据,请进行成功数据,否则返回。如果有错误数据,请进行工作错误数据,否则返回。 CompositeItemwriter将始终致电其中的所有作家。
需要明确的是,就我而言,我有一个读者可以从表中读取信息。处理信息的处理器池,最后填充了DTO。 DTO仅用于从处理器到CompositeItemWriter的信息。 DTO提到了两个对象,一个是成功的,另一个是错误的。每个作家都检查了其在DTO上的领域。
没有类型的意思是“任何功能”;例如, int->真实
和字符串 - > bool
是完全独立的类型,也无法创建两者之间模棱两可的类型。
但是,您可以创建类型函数采用两种类型并返回适当的记录类型:
type ('a, 'b) subject = {algorithm: 'a -> 'b, id: string}
在上述声明之后,(int,real)主题
(例如)(例如)将意味着 {算法:int->真实,ID:字符串}
。
使用“ alpha”和“ beta”类型的正确方法?如果是这样,如何指这些类型?
是的 - “ alpha”和“ beta”正是您发音'a
和'b
的方式。它们不是一个单独的概念。 :-)
此代码将帮助您对UserAction和LoginScreen进行一些更改。
UserAction:
import axios from 'axios'
import {
USER_LOGIN_REQUEST,
USER_LOGIN_SUCCESS,
USER_LOGIN_FAIL,
USER_LOGOUT,
} from '../constants/userConstants'
export const login = (email, password) => async (dispatch) => {
try {
dispatch({
type: USER_LOGIN_REQUEST
})
const config = {
headers: {
'Content-type': 'application/json'
}
}
const { data } = await axios.post(
`api/users/login`,
{ 'username': email, 'password': password },
config
)
dispatch({
type: USER_LOGIN_SUCCESS,
payload: data
})
localStorage.setItem('userInfo', JSON.stringify(data))
} catch (error) {
dispatch({
type: USER_LOGIN_FAIL,
payload: error.response && error.response.data.detail
? error.response.data.detail
: error.message,
})
}
}
这是LoginScreen:
import React, { useState, useEffect } from 'react'
import { Link, useHistory, useLocation } from 'react-router-dom'
import { Form, Button, Row, Col } from 'react-bootstrap'
import { useDispatch, useSelector } from 'react-redux'
import Loader from '../components/Loader'
import Message from '../components/Message'
import FormContainer from '../components/FormContainer'
import { login } from '../actions/userActions'
function LoginScreen() {
const [email, setEmail] = useState('')
const [password, setPassword] = useState('')
const history = useHistory()
const location = useLocation
const dispatch = useDispatch()
const redirect = location.search ? location.search.split('=')[1] : '/'
const userLogin = useSelector(state => state.userLogin)
const { error, loading, userInfo } = userLogin
useEffect(() => {
if (userInfo) {
history.push(redirect)
}
}, [history, userInfo, redirect])
const submitHandler = (e) => {
e.preventDefault()
dispatch(login(email, password))
}
return (
<FormContainer>
<h1>Sign In</h1>
{error && <Message variant='danger'>{error}</Message>}
{loading && <Loader />}
<Form onSubmit={submitHandler}>
<Form.Group controlId='email'>
<Form.Label>Email Address</Form.Label>
<Form.Control
type='email'
placeholder='Enter Email'
value={email}
onChange={(e) => setEmail(e.target.value)}
>
</Form.Control>
</Form.Group>
<Form.Group controlId='password'>
<Form.Label>Password</Form.Label>
<Form.Control
type='password'
placeholder='Enter Password'
value={password}
onChange={(e) => setPassword(e.target.value)}
>
</Form.Control>
</Form.Group>
<Button type='submit' variant='primary'>
Sign In
</Button>
</Form>
<Row className='py-3'>
<Col>
New Customer? <Link
to={redirect ? `/register?redirect=${redirect}` : '/register'}>
Register
</Link>
</Col>
</Row>
</FormContainer>
)
}
export default LoginScreen
只需在
属性上使用linq
Just use LINQ on the
Properties
C#如何在动态对象中获取nth对象属性名称