@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

file.upload set policy explicitly

Summary:
This is pretty basic allowing a user to set the
policy as a valid string ('no-one' or 'users') or
as a valid PHID. Without an explicit policy
a permissive one is set.

Test Plan:
Tested using the python-phabricator module (very basic api wrapper).

The arc cli syntax was evading me.

```import base64
from phabricator import Phabricator
phab = Phabricator()
with open('mypic.jpg') as f:
encoded = base64.b64encode(f.read())

//set no-one as viewer which really means author only?
phab.file.upload(name='mypicnoone.jpg',
data_base64=encoded,
viewPolicy='no-one')

//set a specific phid as policy in this case a project
phab.file.upload(name='mypicphid.jpg',
data_base64=encoded,
viewPolicy='PHID-PROJ-fgvvnafmhvkgn2d5a4rf')

//no set policy ends up as 'users' i.e. ('all users')
phab.file.upload(name='mypicdefault.jpg', data_base64=encoded)```

Not able to really test canCDN attribute but it should be
fine and I tried to make it all consistent with D10166

Reviewers: 20after4, epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: 20after4, epriestley, Korvin

Maniphest Tasks: T5685

Differential Revision: https://secure.phabricator.com/D10164

authored by

cpettet and committed by
epriestley
6a69b469 57c1e0cc

+14 -1
+14 -1
src/applications/files/conduit/FileUploadConduitAPIMethod.php
··· 14 14 return array( 15 15 'data_base64' => 'required nonempty base64-bytes', 16 16 'name' => 'optional string', 17 + 'viewPolicy' => 'optional valid policy string or <phid>', 18 + 'canCDN' => 'optional bool', 17 19 ); 18 20 } 19 21 ··· 29 31 protected function execute(ConduitAPIRequest $request) { 30 32 $data = $request->getValue('data_base64'); 31 33 $name = $request->getValue('name'); 34 + $can_cdn = $request->getValue('canCDN'); 35 + $view_policy = $request->getValue('viewPolicy'); 36 + 37 + $user = $request->getUser(); 32 38 $data = base64_decode($data, $strict = true); 33 - $user = $request->getUser(); 39 + 40 + if (!$view_policy) { 41 + $view_policy = PhabricatorPolicies::getMostOpenPolicy(); 42 + } 34 43 35 44 $file = PhabricatorFile::newFromFileData( 36 45 $data, 37 46 array( 38 47 'name' => $name, 39 48 'authorPHID' => $user->getPHID(), 49 + 'viewPolicy' => $view_policy, 50 + 'canCDN' => $can_cdn, 51 + 'isExplicitUpload' => true, 40 52 )); 53 + 41 54 return $file->getPHID(); 42 55 } 43 56