aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Daemon
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2017-08-22 18:29:51 -0700
committerzotlabs <mike@macgirvin.com>2017-08-22 18:29:51 -0700
commit9f37dbc6dc1798b9b56a683ed1975adc318ff931 (patch)
treed64c789016058cde0fd1ecbb9a0a23bd81b5119a /Zotlabs/Daemon
parent33528c616ae976891df7a778ce9360ceb56571f4 (diff)
downloadvolse-hubzilla-9f37dbc6dc1798b9b56a683ed1975adc318ff931.tar.gz
volse-hubzilla-9f37dbc6dc1798b9b56a683ed1975adc318ff931.tar.bz2
volse-hubzilla-9f37dbc6dc1798b9b56a683ed1975adc318ff931.zip
util/dcp - support recursion and folders full of photos by importing files singly in separate processes - not yet tested
Diffstat (limited to 'Zotlabs/Daemon')
-rw-r--r--Zotlabs/Daemon/Importfile.php45
1 files changed, 45 insertions, 0 deletions
diff --git a/Zotlabs/Daemon/Importfile.php b/Zotlabs/Daemon/Importfile.php
new file mode 100644
index 000000000..5f15b811d
--- /dev/null
+++ b/Zotlabs/Daemon/Importfile.php
@@ -0,0 +1,45 @@
+<?php /** @file */
+
+namespace Zotlabs\Daemon;
+
+class Importfile {
+
+ static public function run($argc,$argv){
+
+ if($argc < 3)
+ return;
+
+ $channel = channelx_by_n($argv[1]);
+ if(! $channel)
+ return;
+
+ $srcfile = $argv[2];
+ $folder = (($argc > 3) ? $argv[3] : '');
+ $dstname = (($argc > 4) ? $argv[4] : '');
+
+ $hash = random_string();
+
+ $arr = [
+ 'src' => $srcfile,
+ 'filename' => (($dstname) ? $dstname : basename($srcfile)),
+ 'hash' => $hash,
+ 'allow_cid' => $channel['channel_allow_cid'],
+ 'allow_gid' => $channel['channel_allow_gid'],
+ 'deny_cid' => $channel['channel_deny_cid'],
+ 'deny_gid' => $channel['channel_deny_gid'],
+ 'preserve_original' => true,
+ 'replace' => true
+ ];
+
+ if($folder)
+ $arr['folder'] = $folder;
+
+ attach_store($channel,$channel['channel_hash'],'import',$arr);
+
+ $sync = attach_export_data($channel,$hash);
+ if($sync)
+ build_sync_packet($channel['channel_id'],array('file' => array($sync)));
+
+ return;
+ }
+}