尝试从Firebase获取一系列子键
func getWavePosts() {
let wavePostRoot = Database.database().reference().child("waves_posts/\(self.waveLabel!)/")
wavePostRoot.observe(.value , with: {snapshot in
var tempKeys = [String]()
for child in snapshot.children {
let snap = child as! DataSnapshot
let key = snap.key {
tempKeys.append(key as String)
}
}
self.tempNames = tempKeys
})
}
我已经对键之前的值进行了此操作,但没有对键进行操作,附加行是已标记的行。在键初始化下方插入一行将错误更改为“无法推断通用参数'Element'”。任何帮助将不胜感激!
---------不带for循环编辑---------
let wavePostRoot = Database.database().reference().child("waves_posts/\(self.waveLabel!)/")
wavePostRoot.observe(.value , with: {snapshot in
var tempKeys = [String]()
self.tempNames.append(snapshot.key)
答案 0 :(得分:1)
您想进行可选绑定,但是忘记了 $refresh_body = @{
client_id='redacted';
client_secret='redacted';
refresh_token='redacted';
grant_type="refresh_token";
}
$refresh_token = Invoke-RestMethod -Uri "https://www.googleapis.com/oauth2/v4/token" -Method POST -Body $refresh_body
$access_token = $refresh_token.access_token
$title = "Scan.pdf"
$description = "scan"
$parentfolder = "redacted" #folder ID where to save
$inputmime = "application/vnd.google-apps.document" #
https://developers.google.com/drive/v2/web/mime-types more on mime types here
$togoogle = "S:\Building_Permit_Tool\Working\0\*.pdf"
##The body must be formatted EXACTLY as below. Any extra linebreaks within
the boundaries will cause Google to return a 400 error
$GUploadBody = @"
Content-Type: application/json; charset=UTF-8
{
"name": "$title",
"parents": [{
"id":"$parentfolder"
}],
"mimeType": "$inputmime",
"description": "$description"
}
--BOUNDARY
Content-Type: application/pdf
$togoogle
--BOUNDARY--
"@
## End HTTP Body
$GBodySize = ($GUploadBody | Measure-Object -property length -sum).Sum #Calculates the size in bytes of the HTTP POST body, necessary for Content- Length in the request header
#Request headers
$Guploadheaders = @{"Authorization" = "Bearer $access_token"
"Content-type" = 'text/plain; boundary="BOUNDARY"'
"Content-Length" = "$GBodySize"
}
$GUploadURI = "https://www.googleapis.com/upload/drive/v3/files?uploadType=media"
$uploadrequest = Invoke-WebRequest -method POST -uri $GUploadURI -body $GUploadBody -Headers $Guploadheaders
$uploadrequest
关键字。另外,我认为您想检查if
是否为snap.key
String