Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mall.oytour.com
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
黄奎
mall.oytour.com
Commits
6a231b8e
Commit
6a231b8e
authored
Sep 25, 2020
by
liudong1993
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
阿里云oss上传文件
parent
d3ef1d69
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
60 additions
and
2 deletions
+60
-2
TransferUploadObject.cs
Mall.Education/AliOSS/TransferUploadObject.cs
+52
-0
Mall.Education.csproj
Mall.Education/Mall.Education.csproj
+4
-0
packages.config
Mall.Education/packages.config
+1
-0
Mall.sln
Mall.sln
+3
-2
No files found.
Mall.Education/AliOSS/TransferUploadObject.cs
0 → 100644
View file @
6a231b8e
using
System
;
using
Aliyun.OSS
;
namespace
COSSnippet
{
public
class
AliOSSUploadObject
{
/// 上传对象
public
void
TransferUploadFile
(
string
filePath
,
string
newFileName
)
{
var
endpoint
=
"<yourEndpoint>"
;
var
accessKeyId
=
"<yourAccessKeyId>"
;
var
accessKeySecret
=
"<yourAccessKeySecret>"
;
var
bucketName
=
"<yourBucketName>"
;
var
objectName
=
"<yourObjectName>"
;
var
localFilename
=
"<yourLocalFilename>"
;
// 创建OssClient实例。
var
client
=
new
OssClient
(
endpoint
,
accessKeyId
,
accessKeySecret
);
try
{
// 上传文件。
client
.
PutObject
(
bucketName
,
objectName
,
localFilename
);
Console
.
WriteLine
(
"Put object succeeded"
);
}
catch
(
Exception
ex
)
{
Console
.
WriteLine
(
"Put object failed, {0}"
,
ex
.
Message
);
}
}
public
void
TransferUpladDel
(
string
Key
)
{
var
endpoint
=
"<yourEndpoint>"
;
var
accessKeyId
=
"<yourAccessKeyId>"
;
var
accessKeySecret
=
"<yourAccessKeySecret>"
;
var
bucketName
=
"<yourBucketName>"
;
var
objectName
=
"<yourObjectName>"
;
// 创建OssClient实例。
var
client
=
new
OssClient
(
endpoint
,
accessKeyId
,
accessKeySecret
);
try
{
// 删除文件。
client
.
DeleteObject
(
bucketName
,
objectName
);
Console
.
WriteLine
(
"Delete object succeeded"
);
}
catch
(
Exception
ex
)
{
Console
.
WriteLine
(
"Delete object failed. {0}"
,
ex
.
Message
);
}
}
}
}
\ No newline at end of file
Mall.Education/Mall.Education.csproj
View file @
6a231b8e
...
@@ -48,6 +48,9 @@
...
@@ -48,6 +48,9 @@
<WarningLevel>
4
</WarningLevel>
<WarningLevel>
4
</WarningLevel>
</PropertyGroup>
</PropertyGroup>
<ItemGroup>
<ItemGroup>
<Reference
Include=
"Aliyun.OSS, Version=2.11.0.0, Culture=neutral, PublicKeyToken=0ad4175f0dac0b9b, processorArchitecture=MSIL"
>
<HintPath>
..\packages\Aliyun.OSS.SDK.2.11.0\lib\net45\Aliyun.OSS.dll
</HintPath>
</Reference>
<Reference
Include=
"Aspose.Pdf"
>
<Reference
Include=
"Aspose.Pdf"
>
<HintPath>
lib\Aspose.Pdf.dll
</HintPath>
<HintPath>
lib\Aspose.Pdf.dll
</HintPath>
</Reference>
</Reference>
...
@@ -95,6 +98,7 @@
...
@@ -95,6 +98,7 @@
<Reference
Include=
"System.Xml"
/>
<Reference
Include=
"System.Xml"
/>
</ItemGroup>
</ItemGroup>
<ItemGroup>
<ItemGroup>
<Compile
Include=
"AliOSS\TransferUploadObject.cs"
/>
<Compile
Include=
"Config.cs"
/>
<Compile
Include=
"Config.cs"
/>
<Compile
Include=
"DBHelper\MySqlHelper.cs"
/>
<Compile
Include=
"DBHelper\MySqlHelper.cs"
/>
<Compile
Include=
"Helper\FileDataHelper.cs"
/>
<Compile
Include=
"Helper\FileDataHelper.cs"
/>
...
...
Mall.Education/packages.config
View file @
6a231b8e
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<
packages
>
<
packages
>
<
package
id
=
"Aliyun.OSS.SDK"
version
=
"2.11.0"
targetFramework
=
"net461"
/>
<
package
id
=
"Microsoft.Diagnostics.Tracing.EventSource.Redist"
version
=
"2.2.0"
targetFramework
=
"net461"
/>
<
package
id
=
"Microsoft.Diagnostics.Tracing.EventSource.Redist"
version
=
"2.2.0"
targetFramework
=
"net461"
/>
<
package
id
=
"MySql.Data"
version
=
"8.0.14"
targetFramework
=
"net461"
/>
<
package
id
=
"MySql.Data"
version
=
"8.0.14"
targetFramework
=
"net461"
/>
<
package
id
=
"Newtonsoft.Json"
version
=
"12.0.3"
targetFramework
=
"net461"
/>
<
package
id
=
"Newtonsoft.Json"
version
=
"12.0.3"
targetFramework
=
"net461"
/>
...
...
Mall.sln
View file @
6a231b8e
...
@@ -43,14 +43,15 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mall.Module.Property", "Mal
...
@@ -43,14 +43,15 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mall.Module.Property", "Mal
EndProject
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mall.AOP", "Mall.AOP\Mall.AOP.csproj", "{231B6093-D5A7-4FEB-A624-7FACE432EA86}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mall.AOP", "Mall.AOP\Mall.AOP.csproj", "{231B6093-D5A7-4FEB-A624-7FACE432EA86}"
EndProject
EndProject
Project("{
FAE04EC0-301F-11D3-BF4B-00C04F79EFBC
}") = "TestCore", "TestCore\TestCore.csproj", "{04A56FD7-DDBC-4FF9-BAC1-C4D257D35CCE}"
Project("{
9A19103F-16F7-4668-BE54-9A1E7A4F7556
}") = "TestCore", "TestCore\TestCore.csproj", "{04A56FD7-DDBC-4FF9-BAC1-C4D257D35CCE}"
EndProject
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Mall.SystemSerivce", "Mall.SystemSerivce", "{646382A6-0092-441C-B202-ED8C3DE015B5}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Mall.SystemSerivce", "Mall.SystemSerivce", "{646382A6-0092-441C-B202-ED8C3DE015B5}"
EndProject
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mall.Education", "Mall.Education\Mall.Education.csproj", "{CE026CAA-B6E6-47F5-9998-181A07679DA0}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mall.Education", "Mall.Education\Mall.Education.csproj", "{CE026CAA-B6E6-47F5-9998-181A07679DA0}"
EndProject
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mall.EducationClient", "Mall.EducationClient\Mall.EducationClient.csproj", "{B665F9E2-C1D6-418C-9A1A-D777E3157799}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mall.EducationClient", "Mall.EducationClient\Mall.EducationClient.csproj", "{B665F9E2-C1D6-418C-9A1A-D777E3157799}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mall.Module.Education", "Mall.Module.Education\Mall.Module.Education.csproj", "{B076F66B-B75E-43DE-B305-764BF3638A91}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mall.Module.Education", "Mall.Module.Education\Mall.Module.Education.csproj", "{B076F66B-B75E-43DE-B305-764BF3638A91}"
EndProject
EndProject
Global
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
GlobalSection(SolutionConfigurationPlatforms) = preSolution
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment