@@ -18,6 +18,11 @@ export default Ember.Component.extend({
1818 objectIcon : null ,
1919 signingUrl : '' ,
2020
21+ filekey : null ,
22+ fileaccesskey : null ,
23+ filepolicy : null ,
24+ filesignature : null ,
25+
2126 uploadPercentage : 0 ,
2227 progressPosition : 0 ,
2328 maxProgressPosition : 100 ,
@@ -56,71 +61,100 @@ export default Ember.Component.extend({
5661 return this . get ( 'spinnerConnectIn' ) ;
5762 } . property ( 'spinnerConnectIn' ) ,
5863
59- /* _bindUploadTarget() {
60- //this._unbindUploadTarget(); // in case it's still bound, let's clean it up first
61- const self = this;
62- const $element = $("#fileformupload");
63- $element.fileupload({
64- url: "/b/put",
65- autoUpload: true,
66- add: function(e, data) {
67- // Automatically upload the file once it is added to the queue
68- var jqXHR = data.submit();
69- },
70-
71- progress: function(e, data) {
72- // Calculate the completion percentage of the upload
73- var progress = parseInt(data.loaded / data.total * 100, 10);
74- console.log(progress);
75- },
76-
77- done: function(e, data) {
78- console.log("success------------");
79- console.log(data);
80- console.log(e);
81- },
82-
83- fail: function(e, data) {
84- console.log("fail------------");
85- console.log(data);
86- console.log(e);
87- }
88- });
89-
90- },*/
91-
9264 _bindUploadTarget ( ) {
9365 //this._unbindUploadTarget(); // in case it's still bound, let's clean it up first
9466 const self = this ;
95- const $element = this . $ ( ) ;
67+ const $element = this . $ ( "#fileformupload" ) ;
9668 $element . fileupload ( {
97- url : "http://192.168.0.115/woww " ,
69+ url : "" ,
9870 pasteZone : $element ,
99- forceIframeTransport : true ,
71+ // forceIframeTransport: true,
10072 autoUpload : true ,
73+ dataType : 'xml' ,
74+ type : 'POST' ,
75+ xhrFields : {
76+ withCredentials : false
77+ }
10178 } ) ;
10279
10380 $element . on ( 'fileuploadsubmit' , ( e , data ) => {
10481 var sign = generateSignature ( {
105- "bucketName" : "woww " ,
82+ "bucketName" : "tron " ,
10683 "acl" : this . get ( 'storageACL' ) ,
10784 "name" : data . files [ 0 ] . name ,
10885 "contentType" : data . files [ 0 ] . type ,
10986 "access_key" : "" ,
11087 "secret_access_key" : "" ,
11188 } ) ;
89+
90+ this . set ( 'filekey' , data . files [ 0 ] . name ) ;
91+ this . set ( 'fileaccesskey' , "" ) ;
92+ this . set ( 'filecontenttype' , data . files [ 0 ] . type ) ;
93+ this . set ( 'filepolicy' , sign . policy ) ;
94+ this . set ( 'filesignature' , sign . signature ) ;
95+ return true ;
96+ } ) ;
97+
98+ $element . on ( "fileuploadprogress" , ( e , data ) => {
99+ self . set ( "uploadPercentage" , parseInt ( data . loaded / data . total * 100 , 10 ) ) ;
100+ } ) ;
101+
102+ $element . on ( "fileuploadsend" , ( e , data ) => {
103+ if ( data . xhr && data . originalFiles . length === 1 ) {
104+ self . set ( "isCancellable" , true ) ;
105+ self . _xhr = data . xhr ( ) ;
106+ }
107+ return true ;
108+ } ) ;
109+
110+ $element . on ( "fileuploadfail" , ( e , data ) => {
111+ //this._resetUpload(true);
112+
113+ //const userCancelled = this._xhr && this._xhr._userCancelled;
114+ //this._xhr = null;
115+
116+ //if (!userCancelled) {
117+ // Discourse.Utilities.displayErrorForUpload(data);
118+ //}
119+
120+ } ) ;
121+
122+ } ,
123+
124+ /*_bindUploadTarget() {
125+ //this._unbindUploadTarget(); // in case it's still bound, let's clean it up first
126+ const self = this;
127+ const $element = this.$();
128+ $element.fileupload({
129+ url: "",
130+ pasteZone: $element,
131+ //forceIframeTransport: true,
132+ //autoUpload: true,
133+ dataType: 'xml',
134+ type: 'POST',
135+ });
136+
137+ $element.on('fileuploadsubmit', (e, data) => {
138+ var sign = generateSignature({
139+ "bucketName": "tron",
140+ "acl": this.get('storageACL'),
141+ "name": data.files[0].name,
142+ "contentType": data.files[0].type,
143+ "access_key": "0RE8HB1CTEW0C13QIEEO",
144+ "secret_access_key": "nS05jbwXswx5x6st1uTy2alIZbwcfvFMQF5CYF0a",
145+ });
112146 data.formData = {
113147 key: data.files[0].name,
114148 acl: this.get('storageACL'),
115- AWSAccessKeyId : "" ,
149+ AWSAccessKeyId: "0RE8HB1CTEW0C13QIEEO ",
116150 "content-type": data.files[0].type,
117151 policy: sign.policy,
118152 signature: sign.signature
119153 };
120154 return true;
121155 });
122156
123- $element . on ( "fileuploadprogressall " , ( e , data ) => {
157+ $element.on("fileuploadprogress ", (e, data) => {
124158 self.set("uploadPercentage", parseInt(data.loaded / data.total * 100, 10));
125159 });
126160
@@ -144,6 +178,6 @@ export default Ember.Component.extend({
144178
145179 });
146180
147- } ,
181+ },*/
148182
149183} ) ;
0 commit comments