11import { MantarayNode } from '@ethersphere/bee-js'
22import fs from 'fs'
33import { Aggregation , LeafCommand } from 'furious-commander'
4+ import { Bytes } from '@ethersphere/bee-js'
45import { BzzAddress , makeBzzAddress } from '../utils/bzz-address'
56import { Download as ManifestDownload } from './manifest/download'
67import { RootCommand } from './root-command'
@@ -14,20 +15,10 @@ export class Download extends RootCommand implements LeafCommand {
1415 public manifestDownload ! : ManifestDownload
1516
1617 private address ! : BzzAddress
17- private actReqHeaders : Record < string , string > = { }
1818
1919 public async run ( ) : Promise < void > {
2020 super . init ( )
2121
22- if ( this . manifestDownload . act ) {
23- this . actReqHeaders = {
24- 'Swarm-Act' : 'true' ,
25- 'Swarm-Act-Timestamp' : this . manifestDownload . actTimestamp ,
26- 'Swarm-Act-History-Address' : this . manifestDownload . actHistoryAddress ,
27- 'Swarm-Act-Publisher' : this . manifestDownload . actPublisher ,
28- }
29- }
30-
3122 this . address = await makeBzzAddress ( this . bee , this . manifestDownload . bzzUrl )
3223
3324 if ( await this . isManifest ( ) ) {
@@ -39,15 +30,18 @@ export class Download extends RootCommand implements LeafCommand {
3930 }
4031
4132 private async downloadData ( ) : Promise < void > {
42- const downloadOptions = this . manifestDownload . act
43- ? {
44- actPublisher : this . manifestDownload . actPublisher ,
45- actHistoryAddress : this . manifestDownload . actHistoryAddress ,
46- actTimestamp : this . manifestDownload . actTimestamp ,
47- }
48- : undefined
33+ let response : Bytes
4934
50- const response = await this . bee . downloadData ( this . address . hash , downloadOptions )
35+ if ( this . manifestDownload . act ) {
36+ const responseAct = await this . bee . downloadFile ( this . address . hash , this . manifestDownload . destination , {
37+ actPublisher : this . manifestDownload . actPublisher ,
38+ actHistoryAddress : this . manifestDownload . actHistoryAddress ,
39+ actTimestamp : this . manifestDownload . actTimestamp ,
40+ } )
41+ response = responseAct . data
42+ } else {
43+ response = await this . bee . downloadData ( this . address . hash , undefined )
44+ }
5145
5246 if ( this . manifestDownload . stdout ) {
5347 process . stdout . write ( response . toUtf8 ( ) )
0 commit comments