以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  蓝版,七牛云sdk上传图片帮忙  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=146857)

--  作者:fntfgz
--  发布时间:2020/3/4 11:37:00
--  蓝版,七牛云sdk上传图片帮忙
蓝版,我需要把本地的照片上传到七牛云上面并接收返回的外部链接,官方也提供了sdk,我没有学过.net语言,自己在论坛上学习了两天也没有一点效果,我也按您提示的把c#的代码转为.net的了,但是还是一点思路也没有,蓝板,我知道这应该是我们自己的问题,但我确实很需要这块,自己真搞不定了,还请蓝板花点时间尽量详细的帮我给个具体的思路,能给代码就给代码吧,sdk这块真不会啊,拜托,感谢
七牛云sdk的链接,
https://developer.qiniu.com/kodo/sdk/1500/csharp-sdk-v7p0
ak:Ehg1pAhTMECUH3ex_oLERYJMoKNrEX5ARi9Rtbag
sk:UI_zfLTJ9Vt9JLd6FkpPsnQJYVPWuI_rz2_volPn
创建的空间名:whale315
[此贴子已经被作者于2020/3/4 14:17:09编辑过]

--  作者:有点蓝
--  发布时间:2020/3/4 15:50:00
--  
下载dll复制到foxtable安装目录,引用下载的dll

比如上传文件

Dim AccessKey As String = "ak:Ehg1pAhTMECUH3ex_oLERYJMoKNrEX5ARi9Rtbag"
Dim SecretKey As String = "UI_zfLTJ9Vt9JLd6FkpPsnQJYVPWuI_rz2_volPn"
Dim Bucket As String = "whale315"
Dim config As new Qiniu.Storage.Config()
config.Zone = Qiniu.Storage.Zone.ZONE_CN_East
Dim mac As new Qiniu.Util.Mac(AccessKey, SecretKey)
Dim bucketManager As new Qiniu.Storage.BucketManager(mac, config)
Dim statRet As Qiniu.Storage.StatResult  = bucketManager.Stat(Bucket, key)
If statRet.Code = 200
    Output.Show(statRet.Result.Hash)
    Output.Show(statRet.Result.MimeType)
    Output.Show(statRet.Result.Fsize)
    Output.Show(statRet.Result.MimeType)
    Output.Show(statRet.Result.FileType)
Else
    Output.Show("stat error: " + statRet.ToString())
End If


--  作者:fntfgz
--  发布时间:2020/3/4 16:24:00
--  

图片点击可在新窗口打开查看此主题相关图片如下:微信截图_20200304162212.png
图片点击可在新窗口打开查看

蓝版,我也引用了呢,但是还是出错,您在帮看看
 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:dll.zip



--  作者:有点蓝
--  发布时间:2020/3/4 17:10:00
--  
不是这2个dll,使用vs打开下载的源码项目,编译,然后找到编译后的qiniu.dll。
--  作者:fntfgz
--  发布时间:2020/3/4 20:21:00
--  
 
 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:qiniu.zip
蓝板,我找到这个dll了,您测试一下,还是出这个错误,我看您的代码,哪里写我要上传的文件地址呢?
[此贴子已经被作者于2020/3/4 20:23:51编辑过]

--  作者:有点蓝
--  发布时间:2020/3/5 9:39:00
--  
dll太老了,需要使用vs编译最新的
 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:qiniu.zip


打开Foxtable安装目录里的Foxtable.exe.config,在以下节点添加红字的这部分内容:

 ……  

  <runtime>  

    <AppContextSwitchOverrides value="Switch.UseLegacyAccessibilityFeatures=false" />  

    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">  

      <dependentAssembly>  

        <assemblyIdentity name="C1.C1Zip.4"  

          publicKeyToken="79882d576c6336da"  

          culture="neutral" />  

        <bindingRedirect oldVersion="4.0.20191.359" newVersion="4.0.20183.338" />  

      </dependentAssembly>  

      <dependentAssembly>  

        <assemblyIdentity name="C1.Win.Bitmap.4"  

          publicKeyToken="944ae1ea0e47ca04"  

          culture="neutral" />  

        <bindingRedirect oldVersion="4.0.20183.338" newVersion="4.0.20191.359" />  

      </dependentAssembly>  

      <dependentAssembly>  

        <assemblyIdentity name="C1.C1Excel.4"  

          publicKeyToken="79882d576c6336da"  

          culture="neutral" />  

        <bindingRedirect oldVersion="4.0.20191.359" newVersion="4.0.20183.338" />  

      </dependentAssembly>  

      <dependentAssembly>  

        <assemblyIdentity name="Newtonsoft.Json"  

          publicKeyToken="30ad4fe6b2a6aeed"  

          culture="neutral" />  

        <bindingRedirect oldVersion="10.0.0.0" newVersion="12.0.0.0" />  

      </dependentAssembly>  

    </assemblyBinding>  

  </runtime>  

……

添加后保存。最后记得备份一下Foxtable.exe.config,因为如果升级Foxtable新版本,这个文件会被覆盖,需要重新改一下。


--  作者:有点蓝
--  发布时间:2020/3/5 9:39:00
--  
\'这里的代码是获取文件信息的,比如文件名称为"1.png"

Dim AccessKey As String = "ak:Ehg1pAhTMECUH3ex_oLERYJMoKNrEX5ARi9Rtbag"
Dim SecretKey As String = "UI_zfLTJ9Vt9JLd6FkpPsnQJYVPWuI_rz2_volPn"
Dim Bucket As String = "whale315"
Dim config As new Qiniu.Storage.Config()
config.Zone = Qiniu.Storage.Zone.ZONE_CN_East
Dim mac As new Qiniu.Util.Mac(AccessKey, SecretKey)
Dim bucketManager As new Qiniu.Storage.BucketManager(mac, config)
Dim key As String = "1.png" 
Dim statRet As Qiniu.Storage.StatResult  = bucketManager.Stat(Bucket, key)
If statRet.Code = 200
    Output.Show(statRet.Result.Hash)
    Output.Show(statRet.Result.MimeType)
    Output.Show(statRet.Result.Fsize)
    Output.Show(statRet.Result.MimeType)
    Output.Show(statRet.Result.FileType)
Else
    Output.Show("stat error: " + statRet.ToString())
End If
[此贴子已经被作者于2020/3/5 9:43:16编辑过]

--  作者:fntfgz
--  发布时间:2020/3/5 22:04:00
--  
感谢蓝版的细心指导,我照猫画虎的也把上传做出来了,帖出来,这个key就要删除了,有需要的换成自己的信息就可以用了
Dim AccessKey As String = "Ehg1pAhTMECUH3ex_oLERYJMoKNrEX5ARi9Rtbag"
Dim SecretKey As String = "UI_zfLTJ9Vt9JLd6FkpPsnQJYVPWuI_rz2_volPn"
Dim Bucket As String = "whale315"
Dim config As new Qiniu.Storage.Config()
config.Zone = Qiniu.Storage.Zone.ZONE_CN_East
config.UseHttps = True
\'config.ChunkSize = ChunkUnit.U512K
config.UseCdnDomains = True
Dim mac As new Qiniu.Util.Mac(AccessKey, SecretKey)
Dim putPolicy As new Qiniu.Storage.PutPolicy()
putPolicy.Scope = bucket
putPolicy.SetExpires(3600)
putPolicy.DeleteAfterDays = 1
Dim jstr As String = putPolicy.ToJsonString()
Dim Auth As new Qiniu.Util.Auth(mac)
Dim token As  String = Auth.CreateUploadToken(mac, jstr)
\'Dim config As new Qiniu.Storage.Config()
Dim um As new Qiniu.Storage.UploadManager(config)

Dim target As  new Qiniu.Storage.FormUploader(config)
Dim filePath As String = "C:\\Users\\86138\\Documents\\Foxtable项目\\管理项目2\\3.png"
Dim key As String = "3.png"
Dim result As new Qiniu.Http.HttpResult
result = target.UploadFile(filePath,key,token,Nothing)
output.show("form upload result: " + result.ToString())