尝试使用适用于 PHP 的 AWS 开发工具包来列出存储桶,但在设置 S3Client 后我不断收到此错误,如下所示:
<?php
require getcwd() . '/aws.phar' /*v3 of the SDK*/;
use Aws\S3\S3Client;
use Aws\Exception\AwsException;
$credentials = new Aws\Credentials\Credentials('I put my', 'credentials here');
$s3 = new Aws\S3\S3Client([
'region' => 'us-east-1', /*also tried different regions*/
'version' => '2006-03-01', /*also tried latest*/
'credentials' => $credentials /*have also tried putting credentials here*/
]);
$s3->listBuckets(); /*still the same error even if I remove this line */ ?>
Run Code Online (Sandbox Code Playgroud)
如果我至少没有填写区域、版本和凭据选项,SDK 实际上会返回一个错误,告诉我填写它们。这是上面代码返回的错误:
致命错误:未捕获错误:调用 phar:///var/www/mail/aws.phar/JmesPath/Lexer.php:343 中未定义的函数 JmesPath\mb_strlen() 堆栈跟踪:#0 phar:///var/ www/mail/aws.phar/JmesPath/Parser.php(76): JmesPath\Lexer->tokenize() #1 phar:///var/www/mail/aws.phar/JmesPath/AstRuntime.php(42) …
所以我正在创建一个C#记事本,我差不多完成了,但是这是最后一个问题:我无法保存文件.当我打开一个文件,修改它并尝试保存它时,它会给我一个错误,说明该文件已被进程使用.我相信这个过程是由我的开放文件方法启动的,但我不确定.我有一个方法来保存打开一个保存文件对话框,但我想要一个不需要对话,只是一个快速 CNTRLŇ保存它,你可能会明白我的意思.
我的打开文件方法
private void openItem_Click(object sender, EventArgs e)
{
Stream myStream;
OpenFileDialog openFileDialog1 = new OpenFileDialog();
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
if ((myStream = openFileDialog1.OpenFile()) != null)
{
string srtfilename = openFileDialog1.FileName;
string filetext = File.ReadAllText(srtfilename);
GetRichTextBox().Text = filetext;
tabControl1.SelectedTab.Text = Path.GetFileName(openFileDialog1.FileName);
GlobalPath = openFileDialog1.FileName;
}
openFileDialog1.Dispose();
}
Run Code Online (Sandbox Code Playgroud)
我的保存文件方法WITH对话框,这个工作,但如果我选择我已经使用的文件,它会崩溃.
private void saveAsItem_Click(object sender, EventArgs e)
{
SaveFileDialog saveFileDialog1 = new SaveFileDialog();
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
using (Stream s = File.Open(saveFileDialog1.FileName, FileMode.Create))
using (StreamWriter sw = new StreamWriter(s)) …Run Code Online (Sandbox Code Playgroud)