-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #222 from tloncorp/add-token-upload
storage: add token-based upload for hosting
- Loading branch information
Showing
10 changed files
with
515 additions
and
229 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
|% | ||
+$ credentials | ||
$: endpoint=@t | ||
access-key-id=@t | ||
secret-access-key=@t | ||
== | ||
:: | ||
+$ configuration | ||
$: buckets=(set @t) | ||
current-bucket=@t | ||
region=@t | ||
== | ||
:: | ||
+$ action | ||
$% [%set-endpoint endpoint=@t] | ||
[%set-access-key-id access-key-id=@t] | ||
[%set-secret-access-key secret-access-key=@t] | ||
[%add-bucket bucket=@t] | ||
[%remove-bucket bucket=@t] | ||
[%set-current-bucket bucket=@t] | ||
[%set-region region=@t] | ||
== | ||
:: | ||
+$ update | ||
$% [%credentials =credentials] | ||
[%configuration =configuration] | ||
action | ||
== | ||
-- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,75 @@ | ||
import { Poke } from '@urbit/http-api'; | ||
import { StorageUpdate, StorageUpdateCurrentBucket, StorageUpdateAddBucket, StorageUpdateRemoveBucket, StorageUpdateEndpoint, StorageUpdateAccessKeyId, StorageUpdateSecretAccessKey, StorageUpdateRegion } from './types'; | ||
import { | ||
StorageUpdate, | ||
StorageUpdateCurrentBucket, | ||
StorageUpdateAddBucket, | ||
StorageUpdateRemoveBucket, | ||
StorageUpdateEndpoint, | ||
StorageUpdateAccessKeyId, | ||
StorageUpdateSecretAccessKey, | ||
StorageUpdateRegion, | ||
StorageService, | ||
StorageUpdateSetPresignedUrl, | ||
StorageUpdateToggleService, | ||
} from './types'; | ||
|
||
const storageAction = <T extends StorageUpdate>( | ||
data: any | ||
): Poke<T> => ({ | ||
const storageAction = <T extends StorageUpdate>(data: any): Poke<T> => ({ | ||
app: 'storage', | ||
mark: 'storage-action', | ||
json: data | ||
json: data, | ||
}); | ||
|
||
export const setCurrentBucket = ( | ||
bucket: string | ||
): Poke<StorageUpdateCurrentBucket> => storageAction({ | ||
'set-current-bucket': bucket | ||
}); | ||
): Poke<StorageUpdateCurrentBucket> => | ||
storageAction({ | ||
'set-current-bucket': bucket, | ||
}); | ||
|
||
export const addBucket = ( | ||
bucket: string | ||
): Poke<StorageUpdateAddBucket> => storageAction({ | ||
'add-bucket': bucket | ||
}); | ||
export const addBucket = (bucket: string): Poke<StorageUpdateAddBucket> => | ||
storageAction({ | ||
'add-bucket': bucket, | ||
}); | ||
|
||
export const removeBucket = ( | ||
bucket: string | ||
): Poke<StorageUpdateRemoveBucket> => storageAction({ | ||
'remove-bucket': bucket | ||
}); | ||
export const removeBucket = (bucket: string): Poke<StorageUpdateRemoveBucket> => | ||
storageAction({ | ||
'remove-bucket': bucket, | ||
}); | ||
|
||
export const setEndpoint = ( | ||
endpoint: string | ||
): Poke<StorageUpdateEndpoint> => storageAction({ | ||
'set-endpoint': endpoint | ||
}); | ||
export const setEndpoint = (endpoint: string): Poke<StorageUpdateEndpoint> => | ||
storageAction({ | ||
'set-endpoint': endpoint, | ||
}); | ||
|
||
export const setAccessKeyId = ( | ||
accessKeyId: string | ||
): Poke<StorageUpdateAccessKeyId> => storageAction({ | ||
'set-access-key-id': accessKeyId | ||
}); | ||
): Poke<StorageUpdateAccessKeyId> => | ||
storageAction({ | ||
'set-access-key-id': accessKeyId, | ||
}); | ||
|
||
export const setSecretAccessKey = ( | ||
secretAccessKey: string | ||
): Poke<StorageUpdateSecretAccessKey> => storageAction({ | ||
'set-secret-access-key': secretAccessKey | ||
}); | ||
): Poke<StorageUpdateSecretAccessKey> => | ||
storageAction({ | ||
'set-secret-access-key': secretAccessKey, | ||
}); | ||
|
||
export const setRegion = (region: string): Poke<StorageUpdateRegion> => | ||
storageAction({ | ||
'set-region': region, | ||
}); | ||
|
||
export const setPresignedUrl = ( | ||
presignedUrl: string | ||
): Poke<StorageUpdateSetPresignedUrl> => | ||
storageAction({ | ||
'set-presigned-url': presignedUrl, | ||
}); | ||
|
||
export const setRegion = ( | ||
region: string | ||
): Poke<StorageUpdateRegion> => storageAction({ | ||
'set-region': region | ||
}) | ||
export const toggleService = ( | ||
service: StorageService | ||
): Poke<StorageUpdateToggleService> => | ||
storageAction({ | ||
'toggle-service': service, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.